Skip to content

Instantly share code, notes, and snippets.

@mastercactapus
Last active February 12, 2017 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mastercactapus/14554bc8379016e766bb0229cf386bf8 to your computer and use it in GitHub Desktop.
Save mastercactapus/14554bc8379016e766bb0229cf386bf8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -ex
(
test -d test-darwin-certs || mkdir test-darwin-certs
cd test-darwin-certs
test -d go || curl -s -L https://storage.googleapis.com/golang/go1.8rc3.darwin-amd64.tar.gz | tar xzv
export GOROOT_BOOTSTRAP="$(pwd)/go"
export GOROOT="$(pwd)/gosrc"
export PATH="$GOROOT/bin:$PATH"
if test -d gosrc
then
cd gosrc
git pull
else
git clone --depth 1 -b darwin_certs https://github.com/mastercactapus/go gosrc
cd gosrc
fi
cd src
./make.bash
cd ../..
cat >test.go <<EOF
package main
import (
"fmt"
"log"
"net/http"
)
const URL = "https://elementary.io/"
func main() {
fmt.Println("GET", URL)
_, err := http.Get(URL)
if err != nil {
log.Fatal(err)
}
}
EOF
_CN=0
_NN=0
_CF=0
_NF=0
export CGO_ENABLED=1
echo "Testing CGO_ENABLED=1 -- Go 1.8 (with fix)"
go run test.go && echo "PASS (yay!)" && _CF=1 || echo "FAIL (fix didn't work')"
export CGO_ENABLED=0
echo "Testing CGO_ENABLED=0 -- Go 1.8 (with fix)"
go run test.go && echo "PASS (yay!)" && _NF=1 || echo "FAIL (fix didn't work')"
export GOROOT="$GOROOT_BOOTSTRAP"
export PATH="$GOROOT/bin:$PATH"
export CGO_ENABLED=1
echo "Testing CGO_ENABLED=1 -- Go 1.8"
go run test.go && echo "PASS (should have failed)" && _CN=1 || echo "FAIL (this is expected)"
export CGO_ENABLED=0
echo "Testing CGO_ENABLED=0 -- Go 1.8"
go run test.go && echo "PASS (should have failed)" && _NN=1 || echo "FAIL (this is expected)"
set +x
echo
echo "The important part:"
echo
echo "************"
echo "CGO 1.8: $_CN"
echo "NOCGO 1.8: $_NN"
echo "CGO fix: $_CF"
echo "NOCGO fix: $_NF"
echo "************"
echo
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment