matryer / xbar-plugins

Plugin repository for xbar (the BitBar reboot)
https://xbarapp.com
2.45k stars 1.04k forks source link

re: Check hosts #806

Closed es-elektron closed 7 years ago

es-elektron commented 7 years ago

FAO: (@christophschlosser)

Trying to run 'checkhosts.1m.go.txt' but I get "env: gorun: No such file or directory".

cschlosser commented 7 years ago

Hey,

please try gorun from here: https://github.com/erning/gorun

Best chris

es-elektron commented 7 years ago

How best to install this on OSX? I only see Ubuntu instructions.

cschlosser commented 7 years ago

Hey,

could you try go get github.com/erning/gorun?

Best chris

martinsirbe commented 7 years ago

Hey guys, didn't want to open a separate issue as I think this is exactly the same issue. I'm on macOS Sierra v10.12.5 and I'm using BitBar v1.9.2 I have installed gorun by running go get github.com/erning/gorun, it's installed correctly and I can execute the following script test.1m.go:

#!/usr/bin/env gorun
package main

import (
    "fmt"
)

func main() {
    fmt.Println("hello friend")
}

When I run the script I get the expected output: image

However, I'm seeing this in the bitbar: image

Can you please give an advice, what I'm doing wrong?

martinsirbe commented 7 years ago

I managed to get it to work by creating a bash script that runs gorun after exporting PATH with GOPATH before running it and pointing it to the test script like this:

#!/usr/bin/env bash

export GOPATH=$HOME/dev/go_workspace
export PATH=$HOME/bin:/usr/local/bin:$GOPATH/bin

gorun $HOME/dev/bitbar/test.1m.sh

Even though this is working, is there a way how to avoid creating a bash script, exporting GOPATH and PATH and then executing the scrip by giving the full path to the script? The other way is to create a valid go app, and then execute it by name after installing it, so you would have something like this in the bash script, where test is the installed go app:

#!/usr/bin/env bash

export GOPATH=$HOME/dev/go_workspace
export PATH=$HOME/bin:/usr/local/bin:$GOPATH/bin

test
cschlosser commented 7 years ago

Actually you can run a compiled go program without an additional bash script, You just have to use the .cgo ending. So the file should look something like this: checkhosts.1m.cgo