Skip to content

Instantly share code, notes, and snippets.

View myitcv's full-sized avatar

Paul Jolly myitcv

View GitHub Profile
@myitcv
myitcv / 0 instructions.sh
Last active April 17, 2018 18:02
stderr stdout demo
go build -o main -tags main && go build -o main2 -tags main2
# run main2 by itself
./main2
# exits with a non-zero exit code and gives:
#
# 1st line to stdout
# 2nd line to stderr
# 3rd line to stdout
@myitcv
myitcv / pragmas.sh
Created April 21, 2018 19:31
Go pragmas
$ cd $GOROOT/src
$ grep -h -r '^[ \t]*//go:' | sort | uniq
//go:a
//go:b
//go:c1
//go:c2
//go:cgo_dynamic_linker "<path>"
//go:cgo_export_dynamic _cgo_panic
//go:cgo_export_dynamic _cgo_topofstack
//go:cgo_export_dynamic crosscall2
@myitcv
myitcv / main.go
Created June 6, 2018 08:32
GopherJS "leaking" repro
// this program demonstrates how fetches through gopherjs seem to be memory leaking.
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
@myitcv
myitcv / README.md
Created June 11, 2018 20:11
Go 1.10.3 accessing a /v2 module

Use Go 1.10.3 which includes minimal module support for vgo transition:

$ cd /tmp
$ curl -s https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz | tar -zx
$ export PATH=/tmp/go/bin:$PATH
$ which go
/tmp/go/bin/go
$ go version
@myitcv
myitcv / main.go
Created June 14, 2018 11:44
Timed go get -u -v g golang.org/x/vgo
package main
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
"time"
)
vgo: finding github.com/moby/moby v17.03.2-ce
vgo: finding github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5
vgo: finding github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3
vgo: finding github.com/vishvananda/netns 604eaf189ee867d8c147fafc28def2394e878d25
vgo: finding github.com/aws/aws-sdk-go v1.4.22
vgo: finding github.com/docker/docker-credential-helpers f72c04f1d8e71959a6d103f808c50ccbad79b9fd
vgo: finding github.com/docker/go-connections ecb4cb2dd420ada7df7f2593d6c25441f65f69f2
vgo: finding github.com/docker/distribution 28602af35aceda2f8d571bad7ca37a54cf0250bc
vgo: finding github.com/fsnotify/fsnotify v1.2.11
vgo: finding golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb
@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

@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 / 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 / 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