On May 21, 2014 7:23 PM, <pe...@scraperwiki.com> wrote:
>
> Hi All,
>
> I'm trying to cross compile for Windows64 from Linux64. I have specified +build constraints. However, when compiling for windows it looks inside the unix.go file, even if I specify // +build !windows and gives me `unknown field in syscall.SysProcAttr` and redefined functions. What am I missing?
>
> Code to reproduce below.
>
> Thanks in advance,
>
> - Peter
>
> $ go version
> go version go1.2.2 linux/amd64
> $ git clone https://gist.github.com/anonymous/9ce13a550a1e8f4574f5; cd 9ce13a550a1e8f4574f5
> $ go build -v
> _/home/pwaller/tmp/9ce13a550a1e8f4574f5
>
> $ GOOS=windows go build -v
> _/home/pwaller/tmp/9ce13a550a1e8f4574f5
> # _/home/pwaller/tmp/9ce13a550a1e8f4574f5
> ./unix.go:7: unknown syscall.SysProcAttr field 'Setsid' in struct literal
> ./windows.go:5: Frobnicate redeclared in this block
> previous declaration at ./unix.go:6
>
> $ cat main.go
> package main
>
> func main() {
> println("Hello, world")
> }
>
> $ cat unix.go
> // +build linux
> package main
put an empty line after the build tag otherwise it won't take effect (it's treated as part of the package docs)
There seems to be a missing empty line after the build directive in unix.go.
-j