Skip to content

Tag: go

Cross-compilation of cgo (for darwin) fails

I am fairly new to go and even Linux in general. I have built an app in a Linux environment which makes use of a gtk lib based on cgo (https://github.com/mattn/go-gtk/). The application builds fine in its native environment (linux 64bit) but when I try to compile for darwin 64bit I get the following result: T…

Getting a pipe status in Go

I’m unable to get a pipe state in Go (1.5). While writing on a mkfifo created pipe, I try to get the state of this output pipe: using the Write return status EPIPE using the Write return status EPIPE and signal.Ignore on SIGPIPE (just in case) using signal.Notify on SIGPIPE I can see that: EPIPE is neve…

Is it possible to break out of a restricted (custom) shell?

Not sure if this is the right place to ask. Say I write a shell that takes stdin input, filters this input so let’s say only certain commands like ls (list contents of binary directory and subdirectory) update (git clone) build (go build) test (go test) start (systemctl start this.service only) stop (sy…

Start a process in Go and detach from it

I need to start a new process in Go with the following requirements: The starting process should run even after the Go process is terminated I need to be able to set the Unix user/group that’s running it I need to be able to set the environment variables inherited I need control over std in/out/err Here…

go install always uses GOROOT/bin instead of GOPATH

I’m having annoying issue with go install command. Every time I try to run it within the src directory of my GOPATH the resulted file is getting created in GOROOT/bin directory for some reason. I verified my environmental variables in .bashrc and also run ‘go env’ (see below) and couldn&#821…

Trying to launch an external editor from within a Go program

I am trying to figure out how to launch an external editor from within a Go program, wait for the user to close the editor, and then continue execution of the program. Based on this SO answer, I currently have this code: When I run the program, I get this: I have also tried using exec.Run() instead of exec.St…