Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

syscall variables undefined

When trying to build the following program on my Mac I get a build error: undefined: syscall.TCPInfo even though that variable is clearly documented http://golang.org/pkg/syscall/#TCPInfo

package main

import "syscall"

func main() {
    _ = syscall.TCPInfo{}
}

Here is my go tool version.

$ go version
go version go1.3 darwin/amd64

I thought this might be an issue a lack of OS support so I tried it on http://play.golang.org, but it looks like many documented variables are just randomly missing from the syscall package: http://play.golang.org/p/w3Uk6NaZVy

Am I missing something?

like image 971
eric chiang Avatar asked Dec 08 '14 15:12

eric chiang


1 Answers

The variable specified inside syscall are OS dependent.

you can add a suffix to the file to specify which os they should be built for:

// +build linux,386 darwin,!cgo

So you can use specific syscall flags for each OS.

like image 85
fabrizioM Avatar answered Nov 02 '22 22:11

fabrizioM