---
title: "Unable to ecaluate expression: function calls not allowed without using call"
author: "bnmnba"
date: "2022-10-25T20:20:31Z"
tags: []
categories: ["编程语言"]
slug: "unable-to-ecaluate-expression-function-calls-not-allowed-without-using-call"
draft: false
lastmod: "2022-10-25T21:06:59Z"
id: 2538665
url: "https://bnmnba.iteye.com/blog/2538665"
---

golang在vscode中调试运行表达式错误：Unable to ecaluate expression: function calls not allowed without using call

```
//golang fiber路由配置函数
	userRouter.Get("/currentUser", func(c *fiber.Ctx) error {
		userId := c.Locals("userId")
		var loginParam *LoginParam = &LoginParam{}
		c.BodyParser(loginParam)
		person := new(Person)
		person.ID = userId.(uint)
		db.First(person, "person_name = ? and person_status= '1'", loginParam.PersonName)
		loginResult := new(LoginResult)
		if person.PersonName == *loginParam.PersonName {
			loginResult.Status = "ok"
			loginResult.Type = *loginParam.LoginType
			loginResult.CurrentAuthority = person.PersonName
		} else {
			loginResult.Status = "not_found"
		}
		return c.JSON(loginResult)
	})
```

  执行断点暂停后，vscode左侧执行表达式：c.Locals("userId")会报错。

解决办法是使用如下表达式：

call c.Locals("userId", nil)

 

 

软件环境：  
VsCode+golang插件开发

go version go1.18.2 windows/amd64