使用Package变量而不是创建局部变量

Consider following code snippet:

var name string

func init() {
   name = "ginny"
}

func test() {
   name, err := ...<some method>..
}

In the method test, name is created as new local variable.

How do I make the test method to use the package variable name instead of creating new local variable?

The := operator always creates new variables. You can it like this:

var name string

func init() {
   name = "ginny"
}

func test() {
   var err error
   name, err = ...<some method>..
}