From 951a2f04ad73dbde82f01ed10f541cc777400233 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 26 Sep 2024 20:54:41 -0500 Subject: [PATCH] Add Find Executables Installed By Go as a Go TIL --- README.md | 3 ++- go/find-executables-installed-by-go.md | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 go/find-executables-installed-by-go.md diff --git a/README.md b/README.md index 04357b6..5b9bfd8 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1445 TILs and counting..._ +_1446 TILs and counting..._ --- @@ -376,6 +376,7 @@ _1445 TILs and counting..._ - [Access Go Docs Offline](go/access-go-docs-offline.md) - [Build For A Specific OS And Architecture](go/build-for-a-specific-os-and-architecture.md) +- [Find Executables Installed By Go](go/find-executables-installed-by-go.md) - [Not So Random](go/not-so-random.md) - [Replace The Current Process With An External Command](go/replace-the-current-process-with-an-external-command.md) - [Sleep For A Duration](go/sleep-for-a-duration.md) diff --git a/go/find-executables-installed-by-go.md b/go/find-executables-installed-by-go.md new file mode 100644 index 0000000..0925148 --- /dev/null +++ b/go/find-executables-installed-by-go.md @@ -0,0 +1,26 @@ +# Find Executables Installed By Go + +When you install an executable using `go install`, it puts that executable in +the `bin` directory designated by the `GOBIN` environment variable. If that env +var isn't set, then it falls back to one of `$GOPATH/bin` or `$HOME/go/bin`. + +When I run `go help install`, it tells me as much: + +``` +Executables are installed in the directory named by the GOBIN environment +variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH +environment variable is not set. +``` + +So, if I am to install something like [`tern`](https://github.com/jackc/tern), + +```bash +$ go install github.com/jackc/tern/v2@latest +``` + +it is going to place that binary in `~/go/bin` for me. + +```bash +$ which tern +/Users/jbranchaud/go/bin/tern +```