Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

How-To Install The KSUID Command Line Tool On A Mac

TODO: Add note that scripts in things like Expans likely won't see the go/bin path, the way around that is to copy the binary to the /usr/local/bin path

I'm using KSUIDs instead of UUIDs for my globally unique identifier needs these days. They're shorter than UUIDs and they sort naturally by creation time which is handy for using them as blog post ids.

The directions for installing the command line tool didn't quite get me there. This is the process I used to get up and running.

First thing: you have to have Go installed. Directions for that are here: go.dev/doc/install

Once you've got Go, run the commands from the install section, they are:

Code

go get -u github.com/segmentio/ksuid

go install github.com/segmentio/ksuid/cmd/ksuid@latest

(Note: I had to add `@latest` to get the install to work. I got an error without it.)

Those commands install the tool on your `$GOPATH` which is not a regular environmental variable. It also wasn't on my path by default so the `ksuid` command didn't work when I tried to run it.

I fixed this by looking up the $GOPATH with:

Code

go env GOPATH

That pointed me to a newly created `go` directory in my home directory (i.e. `/Users/alan/go`). The `ksuid` executable was in a `bin` subdirectory (i.e. `/Users/alan/go/bin/ksuid).

I added that path to my PATH by adding this line to the bottom of my `~/.zshrc` file (which would be `~/.bash_profile` or `~/.bashrc` if you're using `bash` instead of `zsh`)

Code

export PATH="/Users/alan/go/bin:$PATH"

After that, running `ksuid` from the command line worked like a champ.

References:

Code

go install github.com/segmentio/ksuid/cmd/ksuid@latest
cp "" "/usr/local/bin/ksuid"