eric chiang
eric chiang

Reputation: 2745

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?

Upvotes: 12

Views: 11903

Answers (1)

fabmilo
fabmilo

Reputation: 48330

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.

Upvotes: 10

Related Questions