You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/05/04 08:37:39 UTC

[GitHub] [apisix-dashboard] bisakhmondal commented on a change in pull request #1814: fix: store init error from etcd and deferred execution of closers

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:
users@infra.apache.org