You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
varGlobalMap=map[string]struct{}{"MY_GLOBAL_MAP": {}}
varGlobalSlice= []string{"MY_GLOBAL_SLICE"}
funcmain() {}
If I build the program and grep for my magic string, it is in the final binary:
$ go build main.go && strings main | grep -oE "MY_GLOBAL_(MAP|SLICE)"
MY_GLOBAL_MAP
This suggests that this global map is linked into the final binary even if unused. On the other hand, unused global slices are not linked into the final binary.
The text was updated successfully, but these errors were encountered:
Using
go1.12
Consider the following snippet:
If I build the program and grep for my magic string, it is in the final binary:
This suggests that this global map is linked into the final binary even if unused. On the other hand, unused global slices are not linked into the final binary.
The text was updated successfully, but these errors were encountered: