I am trying to use go generate / stringer ( golang.org/x/tools/cmd/stringer) to create String () methods for enumerations. I have problems that I think are related to a slightly different .a package format on different systems. I have this file:
package main
import (
"math/rand"
)
type Foo int;
const (
FooPrime Foo = iota
FooBis
)
func main() {
rand.Seed(1)
}
Now, if I run go, generate example.go on my machine, everything will be fine: foo_string.go is created. However, on the test machine, I get:
stringer: checking package: example.go:4:2: could not import math/rand (reading export data: /usr/lib64/go/pkg/linux_amd64/math/rand.a: go archive is missing __.PKGDEF)
Now, after some digging in the code, I think I'm getting this error, because on my machine rand.a has the following header:
!<arch>
__.PKGDEF 0 0 0 644 2051
`while on the test machine it has the following heading:
!<arch>
__.PKGDEF/ 0 399 399 100644 2051
`
I think the crucial difference is reset after PKGDEFF. gcimporter refuses to process the .a file if it does not contain __. PKGDEF header.
, gcimporter/exportdata.go :
if name != "__.PKGDEF"
:
if name != "__.PKGDEF" && name != "__.PKGDEF\"
( ) go generate example.go.
: ( , )?