0

I'm trying to ship a golang binary inside a Mac application. It is ideally just an HTTP server with some basic functions on folders and files.

The binary seems to work just fine when I run it from a terminal but when I try to call it from my Mac application programmatically it gives me an error "operation not permitted" and quits.

After code-signing with a valid identity file I get the same error.

Error:

go build -ldflags -s .
codesign -s "Developer ID Application: *** *tesco" binaryFile

Golang ENV:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/srinivas/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3n/vpg5bnks45n75n
d91qh7sy3c0000gn/T/go-build925744934=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Srinivas Gowda
  • 371
  • 5
  • 17
  • There [appears](https://www.google.com/search?q=golang+mac+os+x+operation+not+permitted) to be quite a lot of reasons for this, not related to Go actually. Have you investigated further? I mean, the error message is too generic. – kostix Dec 05 '17 at 15:52
  • This may have nothing to do with Go. I guess OS X El Capitan onwards, many resources (mainly files and folders) are protected from malicious activity by System Integrity Protection (SIP). Look at https://www.mikesel.info/fix-operation-not-permitted-root-os-x-terminal/ and https://serverfault.com/questions/748838/sudo-mv-fails-with-operation-not-permitted – Ravi R Dec 05 '17 at 16:28
  • yes I did go through quite a few apple and golang issues and forums to get find out more but nothing where it talks about how to ship a binary or inside a mac app. – Srinivas Gowda Dec 06 '17 at 00:19

1 Answers1

0

This is not related to Go. Go to your system preferences and just give full disk access to the ide you're using.

cigien
  • 57,834
  • 11
  • 73
  • 112