How to fix golang "unrecognized import path"

Recently when trying to run go get I ran into the the following error:

ewilson$ go get github.com/nu7hatch/gouuid
package crypto/md5: unrecognized import path "crypto/md5" (import path does not begin with hostname)

After some trial and error (and a few conflicting opinions) I chose to unset my $GOROOT environment variable. Apparently when you compile go (I use brew for most installations) the correct $GOROOT value becomes embedded in the go tool. When you set it manually you can end up conflicting with the correct setting.

You may actually need to run the unset command as once a variable is set it may only be unset by using the unset command.

ewilson$ unset GOROOT

Onward.

How to repair Homebrew after OS X upgrade

I was getting the following error when running brew after the latest upgrade to OS X (El Capitan).

 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory

I couldn't even run brew update - arg.

This is what I did to correct the issue - git to the rescue!

cd /usr/local/Library

git pull origin master

git pull will throw an error if you have changes in the directory (/usr/local/Library). If so, you'll have to fetch the master branch and perform a hard reset.

git fetch --all

git reset --hard origin/master

You should be able to now use brew again - hurrah!

Note: in the event you installed Homebrew as a non-root user, you'll need to cd to /Users/non-root-user-rname/homebrew/Library instead of /usr/local/Library.

How to restart only the graphical side of OS X via Terminal

I have a variety of mac minis that I use to display stats and system status. Sometimes the Safari browser that is displaying the stats graphs on those remote mac minis locks up / runs out of memory. This makes using Remote Desktop to restart the remote Safari session impossible as I can't login to the machine. Rather than walk over to force a reboot I can ssh into the box and restart the WindowsServer (WindowsServer is the graphical user interface manager and is typically the thing that is borked). 

To resolve this issue I ssh into the machine via Terminal and then run the following command:

sudo killall -HUP WindowServer

Any open applications will be forced to close so use the command with caution.