Skip to content

Instantly share code, notes, and snippets.

View myitcv's full-sized avatar

Paul Jolly myitcv

View GitHub Profile
@myitcv
myitcv / hello_world.py
Created January 3, 2020 19:59
Hello World Examples
class HelloWorld:
def __init__(self, name):
self.name = name.capitalize()
def sayHi(self):
print "Hello " + self.name + "!"
hello = HelloWorld("world")
hello.sayHi()
@myitcv
myitcv / main_test.go
Created March 26, 2019 09:19
testing.Helper failure in panic case
package main
import "testing"
func Test(t *testing.T) {
blah(t, func() {})
blah2(t, func() { panic("oh dear") })
}
func blah(t *testing.T, f func()) {
@myitcv
myitcv / output.txt
Created January 30, 2019 19:22
gg output
$ go test -v -run="Script/command\$" myitcv.io/cmd/gg
=== RUN TestScripts
=== RUN TestScripts/command
=== PAUSE TestScripts/command
=== CONT TestScripts/command
--- PASS: TestScripts (0.06s)
--- PASS: TestScripts/command (10.84s)
<autogenerated>:1:
WORK=$WORK
HOME=/no-home
Hello, World!
Paul Jolly
[email protected]
https://myitcv.io
@_myitcv
* Today we will
- Learn how to say, "Hello, World!"
@myitcv
myitcv / 00_script.sh
Last active November 13, 2018 16:24
godef speed comparison
bash
(
set -eux
command cd $(mktemp -d)
export GOPATH=$(mktemp -d)
export PATH=$GOPATH/bin:$PATH
git clone https://github.com/ianthehat/godef
command cd godef
git checkout f2eb530fb8dbca312f4661b985ec2ae5ba5e7b3a
go install
@myitcv
myitcv / script.txt
Created November 8, 2018 21:40
Creating submodules in a single commit
$ mkdir -p /home/gopher/scratchpad/submodulestest
$ cd /home/gopher/scratchpad/submodulestest
$ git init -q
$ git remote add origin https://github.com/go-modules-by-example-staging/submodulestest
$ go mod init github.com/go-modules-by-example-staging/submodulestest
go: creating new go.mod: module github.com/go-modules-by-example-staging/submodulestest
$ mkdir b
$ cd b
$ cat <<EOD >b.go
package b
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>
@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
@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 / 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