unknown field 'Cloneflags' in struct literal of type syscall.SysProcAttr
punalpatel opened this issue · comments
go get github.com/lizrice/containers-from-scratch 1 ↵ 978 15:29:12
github.com/lizrice/containers-from-scratch
go/src/github.com/lizrice/containers-from-scratch/main.go:33: unknown field 'Cloneflags' in struct literal of type syscall.SysProcAttr
go/src/github.com/lizrice/containers-from-scratch/main.go:49: undefined: syscall.Sethostname
go/src/github.com/lizrice/containers-from-scratch/main.go:52: undefined: syscall.Mount
go/src/github.com/lizrice/containers-from-scratch/main.go:53: undefined: syscall.Mount
Sorry, I don't know how I missed this. You need to build with GOOS=linux. I should add that to the README
I work on Mac with GoLand. And set GOOS=linux. But still got this error. Is there somewhere else I have to set?
I'm afraid I'm not familiar with GoLand, but you should have these defined OK in the Linux version of syscall. What version of Go are you using?
I use Go 1.9. It works fine in Linux.
I guess it is mac that causes the error? Mac OS does not support those sys flags although I set GOOS=Linux.
Anyone has any clue on how to get the flags set for mac OS?
@jebuscraisp if you look at the comments for SysProcAttr you'll see that CloneFlags (and some other fields) are only supported on Linux. To try this on a Mac or Windows machine, you can run Linux in a Virtual Machine.
@Lucier2603 If you put // +build linux
before the package main
like so:
// +build linux
package main
GoLand will stop reporting the error.
Given that this must be built in Linux anyway it really doesn't matter.
For anyone getting errors with VS Code on macOS:
add the following line to settings.json
and restart the editor:
"go.toolsEnvVars": {"GOOS" : "linux"},
@ludwigmuench Doesn't work on mac
If you use IDEA, go to Languages & Frameworks->Go->Build Tags Vendoring to set OS as linux.