This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func Protect(authKey []byte, opts ...Option) func(http.Handler) http.Handler { | |
| //... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Set the Vary: Cookie header to protect clients from caching the response. | |
| w.Header().Add("Vary", "Cookie") | |
| //and | |
| // Clear the request context after the handler has completed. | |
| contextClear(r) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stage('Pre Test'){ | |
| echo 'Pulling Dependencies' | |
| sh 'go version' | |
| sh 'go get -u github.com/golang/dep/cmd/dep' | |
| sh 'go get -u github.com/golang/lint/golint' | |
| sh 'go get github.com/tebeka/go2xunit' | |
| sh 'cd $GOPATH/src/cmd/project && dep ensure' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stage('Test'){ | |
| echo 'Testing, Linting, Vetting, Race Condition Detection' | |
| sh 'go tool vet $GOPATH/src' | |
| sh 'golint $GOPATH/src' | |
| sh 'go test -race -cover' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def notifyBuild(String buildStatus = 'STARTED') { | |
| // build status of null means successful | |
| buildStatus = buildStatus ?: 'SUCCESSFUL' | |
| // Default values | |
| def colorName = 'RED' | |
| def colorCode = '#FF0000' | |
| def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'" | |
| def summary = "${subject} ${env.BUILD_URL}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| node { | |
| try{ | |
| notifyBuild('STARTED') | |
| bitbucketStatusNotify(buildState: 'INPROGRESS') | |
| //..work work.. | |
| }catch (e) { | |
| // If there was an exception thrown, the build failed | |
| currentBuild.result = "FAILED" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stage('Test'){ | |
| echo 'Testing, Linting, Vetting, Race Condition Detection' | |
| //List all our project files with 'go list ./... | grep -v /vendor/ | grep -v github.com | grep -v golang.com' | |
| sh 'go tool vet $(go list ./... | grep -v /vendor/ | grep -v github.com | grep -v golang.com)' | |
| sh 'golint $(go list ./... | grep -v /vendor/ | grep -v github.com | grep -v golang.com)' | |
| sh 'go test $(go list ./... | grep -v /vendor/ | grep -v github.com | grep -v golang.com) -race -cover' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| node { | |
| try{ | |
| notifyBuild('STARTED') | |
| bitbucketStatusNotify(buildState: 'INPROGRESS') | |
| ws("${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_ID}/") { | |
| withEnv(["GOPATH=${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_ID}"]) { | |
| env.PATH="${GOPATH}/bin:$PATH" | |
| stage('Checkout'){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stage('Test'){ | |
| //List all our project files with 'go list ./... | grep -v /vendor/ | grep -v github.com | grep -v golang.org' | |
| //Push our project files relative to ./src | |
| sh 'cd $GOPATH && go list ./... | grep -v /vendor/ | grep -v github.com | grep -v golang.org > projectPaths' | |
| //Print them with 'awk '$0="./src/"$0' projectPaths' in order to get full relative path to $GOPATH | |
| def paths = sh returnStdout: true, script: """awk '\$0="./src/"\$0' projectPaths""" | |
| echo 'Vetting' |