`go list` prints out non-existing Target - go

As per golint's README.md:
To find out where golint was installed you can run `go list -f {{.Target}} golang.org/x/lint/golint`.
When I run the command I get:
/Users/Marko/go/bin/golint
But there is no such file:
ls -alF /Users/Marko/go/bin/
total 6432
drwxr-xr-x 3 Marko staff 96 Nov 29 12:32 ./
drwxr-xr-x 4 Marko staff 128 Nov 29 12:05 ../
-rwxr-xr-x 1 Marko staff 3289296 Nov 29 12:32 hello*
How can I find out where is golint?

You need to install it first. Run go get -u golang.org/x/lint/golint. I'm not sure why does go list still list it as a Target, even if it is not installed.

Related

How to run parametrized bash scripts in Docker CLI

I have an issue that I'm not able to solve. I want to run a bash script that is inside my Docker CLI container, and I want to execute it, passing parameters. Usually, I run scripts using a notation like this:
docker exec -i $CLI_ID bash "./script.sh"
But I don't know how to pass parameters to the script. I tried to execute it with:
docker exec -i $CLI_ID bash "./script.sh PARAM"
But it doesn't work. How can I do it?
Thanks
Try with bash -c option
docker exec -i $CLI_ID bash -c "./script.sh PARAM"
Hope this helps.
Make sure the script is executable , then you dont need the bash and double quotes etc. Just run it striaght away by path/name and provide the options.
[root#ap-p1m-ff ~]# docker exec -i 0c cat /tmp/test.sh
#!bin/bash
ls $1
[root#ap-p1m-ff ~]# docker exec -i 0c /tmp/test.sh -l
total 4
-rw-r--r-- 1 root root 159 Jun 4 18:32 RELEASE
drwxr-xr-x 2 root root 120 Jun 4 18:33 assets
drwxr-xr-x 1 root root 31 Jun 4 18:33 bin
drwxr-xr-x 2 root root 6 Apr 12 2016 boot
drwxr-xr-x 5 root root 340 Jun 7 19:50 dev
drwxr-xr-x 1 root root 22 Jun 7 19:50 etc
but if the script is not already executble the bash should work as well:
[root#ap-p1m-ff ~]# docker exec -i 0c bash /tmp/test.sh -l
total 4
-rw-r--r-- 1 root root 159 Jun 4 18:32 RELEASE
drwxr-xr-x 2 root root 120 Jun 4 18:33 assets
drwxr-xr-x 1 root root 31 Jun 4 18:33 bin
drwxr-xr-x 2 root root 6 Apr 12 2016 boot
drwxr-xr-x 5 root root 340 Jun 7 19:50 dev
drwxr-xr-x 1 root root 22 Jun 7 19:50 etc
drwxr-xr-x 2 root root 6 Apr 12 2016 home
drwxr-xr-x 1 root root 45 Sep 13 2015 lib
drwxr-xr-x 2 root root 34 May 15 14:22 lib64
drwxr-xr-x 2 root root 6 May 15 14:22 media
Add your parameter as a separate argument rather than as part of the filename:
docker exec -i "$CLI_ID" bash "./script.sh" PARAM
This way, you don't have to add another level of escaping to the parameter.

/usr/local/bin doesn't exist when trying to add symlink for SublimeText3

I have been researching this question for 2 hours now and have done everything in all of the answers for creating a symlink for SublimeText3 in macOS Sierra using iTerm2. I have tried all of the following:
input: ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
returns: ln: /usr/local/bin/subl: No such file or directory
input: ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
returns: ln: /Users/david/bin/subl: No such file or directory
I have tried creating /usr/local/bin/subl and then executing the above commands but when I use mkdir /usr/local/bin it returns File exists but when I try to run the ln command, I get the same return as examples 1 and 2.
In usr/local it shows: bin remotedesktop but when I try cd bin it returns -bash: cd: bin: No such file or directory and when I look for it in Finder it I get the following error message: The operation can’t be completed because the original item for “bin” can’t be found.
Here is my $PATH: echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I'm hoping someone can either help me or point in the direction of an answer I missed, because so far none of the answers have worked for me.
When I ran echo b | xxd
this was the result:
00000000: 486f 6d65 6272 6577 2062 696e 206c 6962 Homebrew bin lib
00000010: 2073 6269 6e0a sbin.
Results of running: ls -l /usr/local | cat -vet | pbcopy
total 0$
drwxr-xr-x 2 root wheel 68 Sep 8 22:04 Cellar$
drwxrwxr-x 2 david admin 68 Sep 8 22:04 Frameworks$
drwxr-xr-x 2 root wheel 68 Sep 8 22:04 Homebrew$
drwxrwxr-x 3 david admin 102 Sep 9 00:14 bin$
drwxrwxr-x 2 david admin 68 Sep 8 22:04 etc$
drwxrwxr-x 2 david admin 68 Sep 8 22:04 include$
drwxrwxr-x 2 david admin 68 Sep 8 22:04 lib$
drwxr-xr-x 2 root wheel 68 Sep 8 22:04 opt$
drwxr-xr-x 3 root wheel 102 Jun 12 17:38 remotedesktop$
drwxrwxr-x 2 david admin 68 Sep 8 22:04 sbin$
drwxrwxr-x 3 david admin 102 Sep 8 22:04 share$
drwxrwxr-x 2 david admin 68 Sep 8 22:04 var$

Compilation fails: No such file or directory (but it DOES exist!)

I'm trying to compile the Ethereum Go client. Following the instructions I simply run make geth, but that fails:
$ make geth
build/env.sh go run build/ci.go install ./cmd/geth
make: build/env.sh: No such file or directory
make: *** [geth] Error 1
As far as I understand from this error it complaints that either build/env.sh or build/ci.go doesn't exist. So I checked out the build folder, but they both seem to be there:
$ ls -l build
total 648
drwxr-xr-x 3 kramer65 staff 102 Feb 13 13:45 _vendor
-rw-r--r-- 1 kramer65 staff 2892 Feb 13 13:45 ci-notes.md
-rw-r--r-- 1 kramer65 staff 30516 Feb 13 13:45 ci.go <===
-rw-r--r-- 1 kramer65 staff 123 Feb 13 13:45 deb.changelog
... some other files here
-rw-r--r-- 1 kramer65 staff 379 Feb 13 13:45 deb.rules
-rwxr-xr-x 1 kramer65 staff 721 Feb 13 13:45 env.sh <===
-rw-r--r-- 1 kramer65 staff 1722 Feb 13 13:45 mvn.pom
... and some more files here
I checked whether go is installed and which version it is:
$ which go
/usr/local/bin/go
$ go version
go version go1.7.5 darwin/amd64
So go seems to be fine.
Does anybody have any idea how I can debug/solve this? All tips are welcome!
Ok, nevermind. Found it. The problem was that line endings where in dos style.
So to recursively convert line endings to unix I ran:
find . -type f -print0 | xargs -0 -n 1 -P 4 dos2unix
and then tried building again. That fixed it.
I hope this helps someone else here. In any case I wish you all a beautiful day!
I solve the problem using by following instructions below. I don't know the reason, but I completely get rid of brew to make it run. (mac)
1 install go(I used package)
2 git clone https://github.com/ethereum/go-ethereum
3 cd go-ethereum && git checkout tags/v1.8.2
4 run `find . -type f -print0 | xargs -0 -n 1 -P 4 dos2unix`(if you don't have dos2unix, you could brew one, it does not break anything.)
5 make geth
6 ln -s /path/to/origin/geth /path/to/target/geth
Then run which geth you could find your geth. Run geth version you can see your version.

Successfully delete stringutil.a but it comes back on its own

I'm following "How to Write Go Code" and tries to delete stringutil.a under $GOPATH/pkg/darwin_amd64/github.com/user. The delete is successful but the file comes back on its own. I'm confused. What is happening?
zps-MacBook-Air:haibin haibin$ rm stringutil.a
zps-MacBook-Air:haibin haibin$ ls -lah
total 0
drwxr-xr-x 2 haibin staff 68B Feb 15 00:57 .
drwxr-xr-x 17 haibin staff 578B Feb 15 00:39 ..
zps-MacBook-Air:haibin haibin$ ls -lah
total 8
drwxr-xr-x 3 haibin staff 102B Feb 15 00:57 .
drwxr-xr-x 17 haibin staff 578B Feb 15 00:39 ..
-rw-r--r-- 1 haibin wheel 2.4K Feb 15 00:57 stringutil.a
You need to delete the stringutil.go source file that is under the src tree. The *.a file is a binary file which results from the compilation (and possibly linking) of source files.

what is ~/.npm dir for?

I have installed the global npm package jslint and it lives here
$ ls -la /usr/local/bin/jslint
lrwxr-xr-x 1 lust admin 40 Feb 12 15:31 /usr/local/bin/jslint -> ../lib/node_modules/jslint/bin/jslint.js
$ ls -la /usr/local/lib/node_modules/jslint/bin
total 8
drwxr-xr-x 3 lust staff 102 Apr 16 2012 .
drwxr-xr-x 10 lust staff 340 Feb 12 15:31 ..
-rwxr-xr-x 1 lust staff 2330 Apr 16 2012 jslint.js
$ which jslint
/usr/local/bin/jslint
$ head -3 /usr/local/bin/jslint
#!/usr/bin/env node
var linter = require("../lib/linter");
So it is without any doubt whatsoever at this point that jslint is in fact being run from this dir and not here:
$ ls -la .npm/jslint/0.1.9/package/bin/
total 8
drwxr-xr-x 3 lust staff 102 Apr 16 2012 .
drwxr-xr-x 9 lust staff 306 Feb 12 15:31 ..
-rwxr-xr-x 1 lust staff 2330 Apr 16 2012 jslint.js
There appear to be two copies of the package, one in /usr/local/ and one in ~/.npm. Why is there one in .npm and is it safe for me to remove it?
~/.npm is a cache that npm uses to avoid re-downloading the same package multiple times. There's no harm in removing it. You can empty it with the command:
npm cache clean

Resources