Why is lint giving a warning ineffectual assignment to (ineffassign)

Getting a lint warning ineffectual assignment to "cfg" at line cfg := &utils.Config{}. Why is that ? After the following if statement, cfg is written, thus the value assigned to cfg using cfg := &utils.Config{} is never used. You are using an assignment where a declaration would do.

Getting a lint warning ineffectual assignment to "cfg" at line cfg := &utils.Config{}. Why is that ?

 cfg := &utils.Config{} env := os.Getenv("TEST") if strings.EqualFold(env, "INT") { cfg = utils.GetIntConfig() } else { cfg = utils.GetConfig() } cgw.Cgw(cfg) 
1

1 Answer

After the following if statement, cfg is written, thus the value assigned to cfg using cfg := &utils.Config{} is never used. You are using an assignment where a declaration would do.

var cfg *utils.Config ... 
2

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobXFoaWiFeIGOsJ%2ByZZmoeq21za1koKGmnruoecBmrpqqnp67qHnIp5yfnpWYwbaty2aYrKuZnLuusc2tZK2nXZ67prLFmqqsoZej

 Share!