Skip to content

Instantly share code, notes, and snippets.

View myitcv's full-sized avatar

Paul Jolly myitcv

View GitHub Profile
@myitcv
myitcv / README.txt
Last active October 12, 2018 08:41
goget
goget [-i|-r|-p] [-n] packages
goget resolves (and installs or runs) main packages.
The packages argument to goget is similar to that of go get (in module mode) but the list of packages must strictly
be main packages that are part of Go modules. The rule for default package version (and overrides via @version) is
the same as go get. Hence goget main_pkg@latest has the same version semantics as go get main_pkg@latest.
With no flags, goget installs the main packages to goget/pkg/$module/$main_pkg@$version under your user cache directory.
See the documentation for os.UserCacheDir for OS-specific details on how to configure its location.
git clone https://github.com/gobuffalo/buffalo /tmp/buffalo
cd /tmp/buffalo
go mod download
(echo "digraph {"; echo "graph [rankdir=TB, overlap=false];"; go mod graph 2>/dev/null | awk '{print "\""$1"\" -> \""$2"\""};'; echo "}" ) | twopi -Tpng > graph.png
display graph.png
@myitcv
myitcv / 00 buffalo.txt
Last active December 18, 2021 20:57
Unstable go mod tidy
$ git clone --depth=1 --branch v0.13.0 https://github.com/gobuffalo/buffalo
Cloning into 'buffalo'...
$ cd buffalo
$ go mod download
go: finding github.com/markbates/oncer v0.0.0-20181014194634-05fccaae8fc4
go: finding github.com/markbates/inflect v1.0.1
go: finding github.com/gobuffalo/mw-paramlogger v0.0.0-20181005191442-d6ee392ec72e
go: finding github.com/gobuffalo/mw-i18n v0.0.0-20180802152014-e3060b7e13d6
go: finding github.com/gobuffalo/mw-contenttype v0.0.0-20180802152300-74f5a47f4d56
go: finding github.com/markbates/refresh v1.4.10

Take https://github.com/myitcv/gobin/commits/master as an example.

The repo uses squash merging:

screen shot 2018-10-25 at 10 05 43

This results in, for example (#12) being added to the first line of the squash commit on the target branch.

This is useful when reviewing commits on GitHub itself, e.g. via the link above, because you can click through to the corresponding PR.

@myitcv
myitcv / gist:27729e7f6a682133de2bb7f7625bc6c6
Created October 28, 2018 21:36
gopkg.in/sorcix/irc.v2 to modules
$ git clone https://github.com/sorcix/irc /tmp/irc
Cloning into '/tmp/irc'...
$ cd /tmp/irc
$ git checkout origin/v2
HEAD is now at 63eed78... Merge pull request #33 from TrueFurby/patch-1
$ go mod init
go: creating new go.mod: module gopkg.in/sorcix/irc.v2
$ go mod tidy
$ cd $(mktemp -d)
$ go mod init example.com/hello
package main
import (
"fmt"
"os"
"strings"
"mvdan.cc/sh/syntax"
)
@myitcv
myitcv / output.txt
Last active April 25, 2019 16:47
github.com/sirupsen/logrus pain
$ GO111MODULE=off go get github.com/myitcv/gobin
$ gobin github.com/rogpeppe/gohack
Installed github.com/rogpeppe/[email protected] to /home/gopher/gopath/bin/gohack
$ gobin github.com/rogpeppe/gomodmerge
Installed github.com/rogpeppe/[email protected] to /home/gopher/gopath/bin/gomodmerge
$ cd $(mktemp -d)
$ go mod init example.com/hello
$ cat <<EOD >main.go
package main
@myitcv
myitcv / 00_repro.sh
Created October 31, 2018 21:41
goimports speed repro
(
set -eo pipefail
export GOPATH=$(mktemp -d)
export GO111MODULE=off
go get golang.org/x/tools/cmd/goimports
cd $(go list -f "{{.Dir}}" golang.org/x/tools/go/packages)
git fetch https://go.googlesource.com/tools refs/changes/97/142697/6 && git checkout FETCH_HEAD
sed -i 's/^var Debug = false$/var Debug = true/' golist.go
go install golang.org/x/tools/cmd/goimports
export GO111MODULE=on
@myitcv
myitcv / 00_repro.sh
Created October 31, 2018 22:41
goimports speed repro fix
set -eo pipefail
export GOPATH=$(mktemp -d)
export GO111MODULE=off
go get golang.org/x/tools/cmd/goimports
cd $(go list -f "{{.Dir}}" golang.org/x/tools/go/packages)
git fetch https://go.googlesource.com/tools refs/changes/97/142697/6 && git checkout FETCH_HEAD
sed -i 's/^var Debug = false$/var Debug = true/' golist.go
sed -i '/cmd\.Env = append/c\cmd.Env = append(append([]string{}, cfg.Env...), "PWD="+cfg.Dir, "GOPROXY=off")' golist.go
go install golang.org/x/tools/cmd/goimports
export GO111MODULE=on
SCRIPT /home/myitcv/.vim/ftplugin/go.vim
Sourced 1 time
Total time: 0.000160
Self time: 0.000160
count total (s) self (s)
1 0.000065 nmap <buffer> <Leader>h : <C-u>call go#tool#Info(0)<CR>
1 0.000024 nmap <F6> :GoImports<CR>