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
{{ message }}
Repository navigation
cmd/compile: linker does not elide unused global maps #31704
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.
Activity
randall77 commentedon Apr 27, 2019
I'm pretty sure this is #2559.