Closed jefferai closed 2 years ago
@jefferai What are the flags used for compiling? I'm trying to replicate the issue, but fail with this simple example:
package main
import (
"log"
"github.com/zalando/go-keyring"
)
func main() {
service := "my-app"
user := "anon"
password := "secret"
// set password
err := keyring.Set(service, user, password)
if err != nil {
log.Fatal(err)
}
// get password
secret, err := keyring.Get(service, user)
if err != nil {
log.Fatal(err)
}
log.Println(secret)
}
CGO_ENABLED=0 GOOS=linux go build
file go-keyring
go-keyring: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=3YHhCPmk4UlD9_lXoVn1/N8KAugbp9D6MWwgxw4DH/ztCw71yTYMPVgjk8hI8h/yBdWR56JPIAmab6xbFtI, not stripped
Try GOOS=freebsd GOARCH=amd64
Probably only GOOS is needed though (and keeping CGO_ENABLED=0)
@jefferai New version v0.2.1 addresses the issue.
Thank you!
In 0.2.0, the file
keyring_linux.go
was renamed tokeyring_unix.go
to enable dbus on more platforms.Unfortunately, the dbus implementation in
godbus/dbus
requirescgo
for both dragonflybsd and freebsd. This means that if you are building with cgo disabled to build static binaries or for easier cross-compilation, upgrading to v0.2.0 results in build failures, with no way to disable this functionality.One option would be to put a build tag constraint on cgo in
keyring_unix.go
to not compile in the code if cgo is disabled. That would probably require a copy of the file to be available for non-dragonflybsd/freebsd platforms that still compiles if cgo is disabled.