bisakhmondal commented on a change in pull request #1814:
URL: https://github.com/apache/apisix-dashboard/pull/1814#discussion_r625604849



##########
File path: api/cmd/managerapi.go
##########
@@ -65,6 +66,14 @@ func printVersion() {
 
 // NewManagerAPICommand creates the manager-api command.
 func NewManagerAPICommand() *cobra.Command {
+       cobra.OnInitialize(func() {
+               var err error
+               service, err = createService()

Review comment:
       Hi @tokers, I'm afraid that's not possible here due to variable 
shadowing.
   
   `service` is a global variable and assignment through go's short assignment 
operator (`:=`) will create a brand new `service` var in this scope without 
referencing the global one.
   
   I looked into the docs and also cross-checked 
[ref](https://golang.org/ref/spec#Declarations_and_scope)
   >An identifier declared in a block may be redeclared in an inner block. 
While the identifier of the inner declaration is in scope, it denotes the 
entity declared by the inner declaration.
   
   Anyway, Thank you. Got the scope to re-read the docs :)
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to