Hello, just getting into go these last few days.
I wrote some code on an Ubuntu VM that compiles and runs fine. Then I decided to develop on my Mac workstation, but the same code fails to compile.
I get the following error:
./ds-as-mounter.go:57:9: undefined: unix.Mount
./ds-as-mounter.go:57:35: undefined: unix.MS_BIND
Oddly it seems OK with unix.Unmount
.
I did install the unix package with go get -u golang.org/x/sys/unix
.
Here is the top of my package:
package main
import (
"fmt"
"golang.org/x/sys/unix"
"os"
"regexp"
"sync"
)
//....
And here is where the Mount and Unmount calls are made:
func mount(src, dest string, wg *sync.WaitGroup) {
defer wg.Done()
//fmt.Println("Mounting", src, dest)
err := unix.Mount(src, dest, "", unix.MS_BIND, "")
if err != nil {
fmt.Println(src, dest, err)
}
}
func unmount(dest string, wg *sync.WaitGroup) {
defer wg.Done()
//fmt.Println("Unmounting", dest)
err := unix.Unmount(dest, 0)
if err != nil {
fmt.Println("Unmount", dest, err)
}
}
Note that the compiler complains about unix.Mount
and unix.MS_BIND
, not unix.Unmount
.
I’m quite confused. Any help would be appreciated. Thanks!
go version go1.11.2 darwin/amd64