Skip to content

Instantly share code, notes, and snippets.

View myitcv's full-sized avatar

Paul Jolly myitcv

View GitHub Profile
package main
import (
"fmt"
"os"
"strings"
"mvdan.cc/sh/syntax"
)
@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

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 / 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
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 / 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.
@myitcv
myitcv / script.sh
Created September 25, 2018 13:48
gocode issue repro script: no completions
export GOPATH=$(mktemp -d)
cd $GOPATH
mkdir -p src/example.com/hello
cd src/example.com/hello
export GOBIN=$PWD/.bin
export PATH=$GOBIN:$PATH
echo "package main" > pkg.go
go get github.com/mdempsky/gocode
pushd $(go list -f "{{.Dir}}" github.com/mdempsky/gocode)
git checkout 00e7f5ac290aeb20a3d8d31e737ae560a191a1d5
@myitcv
myitcv / 00 scenario.txt
Last active September 25, 2018 10:35
gocode and godef issue repo
$ export GOPATH=/tmp/tmp.INWBhiKAgt
$ cd /tmp/tmp.eoCQw0fOCT
$ mkdir hello
$ cd hello
$ export GOBIN=/tmp/tmp.opPK4KUGiw/hello/.bin
$ export PATH=/tmp/tmp.opPK4KUGiw/hello/.bin:/root/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$ go mod init example.com/hello
go: creating new go.mod: module example.com/hello
$ echo "package main" >pkg.go
$ go get github.com/ianthehat/[email protected]
@myitcv
myitcv / aa_readme.md
Last active September 10, 2018 16:53
"Global" module-aware install script for Go 1.11

Usage

./install.sh <pkg list>

Issues

  • Specific to git (fixable)
  • Does not support specification of a major import path (fixable)
@myitcv
myitcv / report.md
Last active November 7, 2018 23:25
Experience report for creating a submodule within an existing module

Background

GopherJS is a compiler from Go to JavaScript that targets browser VMs.

The package github.com/gopherjs/gopherjs is the compiler program, responsible for transpiling Go code to JavaScript.

The package github.com/gopherjs/gopherjs/js provides an API for interacting with native JavaScript.

Because of the limited runtime environment afforded by a JavaScript VM (especially in the browser), GopherJS provides