[pkg-golang-devel] Bug#818651: Bug#818651: golang: cannot use net package without CGO
Michael Hudson-Doyle
michael.hudson at canonical.com
Sun Mar 20 08:08:16 UTC 2016
Hi,
On 19 March 2016 at 22:03, Ayke van Laethem <aykevanlaethem at gmail.com> wrote:
> Package: golang
> Version: 2:1.6-1
> Severity: normal
>
> Dear Maintainer,
>
> Golang 1.3 (jessie) can build this file just fine without CGO, but golang 1.5
> and 1.6 throws an error:
>
> package main
>
> import (
> "fmt"
> "net"
> )
>
> func main() {
> fmt.Println("HostPort:", net.JoinHostPort("google.com", "80"))
> }
>
> To reproduce, compile this with the environment variable CGO_ENABLED=0. It
> fails with golang 1.5 (jessie-backports) and golang 1.6 (testing) but succeeds
> in golang 1.3 (jessie).
Well. It _succeeds_ in that it produces an executable without error in
jessie, but it does not actually _work_ in the sense that the
executable thus produced still uses cgo:
root at figurable-tamatha:~# CGO_ENABLED=0 go install nocgo
root at figurable-tamatha:~# ldd gopath/bin/nocgo
linux-vdso.so.1 (0x00007ffea37fb000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbbf1bcc000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbbf1821000)
/lib64/ld-linux-x86-64.so.2 (0x000055b2c0397000)
so I don't think reverting to the behaviour of the 1.3 packaging (even
if it were possible) would actually be a good idea :-)
This is all because Go <1.4 never rebuilt the standard library in the
usual course of things even when it arguably should, like here.
> The exact (but cryptic) error reported is:
>
> go install net: open /usr/lib/go/pkg/linux_amd64/net.a: permission denied
>
> Since Go 1.2 (according to the docs [1]) it should be possible to use the net
> package without CGO on some systems.
> My system is linux-amd64 (one with jessie and one with testing).
You can build the executable, but you have to use 'go build' and not
'go install'.
This is all reminiscent of the conversation after
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=776401#27 although
it's a bit worse than that because the set up here really wants to
replace GOROOT/pkg/linux_amd64/net.a, not install another one.
More information about the pkg-golang-devel
mailing list