From d5fb1c07744c05fbeaf490ae6bef49db3fb266c3 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Fri, 1 Sep 2017 12:47:53 -0400 Subject: [PATCH] rm -r golang This is not the recommended way to write Go projects and is pointless to keep around. --- golang/.godir | 1 - golang/Dockerfile | 1 - golang/README.md | 79 ----------------------------------------------- golang/build | 18 ----------- golang/cover | 27 ---------------- golang/test | 56 --------------------------------- 6 files changed, 182 deletions(-) delete mode 100644 golang/.godir delete mode 100644 golang/Dockerfile delete mode 100644 golang/README.md delete mode 100755 golang/build delete mode 100755 golang/cover delete mode 100755 golang/test diff --git a/golang/.godir b/golang/.godir deleted file mode 100644 index 9304fba30..000000000 --- a/golang/.godir +++ /dev/null @@ -1 +0,0 @@ -github.com/coreos/docs diff --git a/golang/Dockerfile b/golang/Dockerfile deleted file mode 100644 index 464c7fd32..000000000 --- a/golang/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM golang:onbuild diff --git a/golang/README.md b/golang/README.md deleted file mode 100644 index f1ebcd1d6..000000000 --- a/golang/README.md +++ /dev/null @@ -1,79 +0,0 @@ -# Go at CoreOS - -We use Go (golang) a lot at CoreOS, and we’ve built up a lot of internal knowledge about how best to develop Go projects. - -This document serves as a best practices and style guide for how to work on new and existing CoreOS projects written in Go. - -## Version - -- Wherever possible, use the [latest official release][go-dl] of go -- Any software shipped in the Container Linux image should be developed against the [versions shipped in the Container Linux image](https://github.com/coreos/coreos-overlay/tree/master/dev-lang/go) - -[go-dl]: https://golang.org/dl/ - -## Style - -Go style at CoreOS essentially just means following the upstream conventions: - - [Effective Go][effectivego] - - [CodeReviewComments][codereview] - - [Godoc][godoc] - -It's recommended to set a save hook in your editor of choice that runs `goimports` against your code. - -[effectivego]: https://golang.org/doc/effective_go.html -[codereview]: https://github.com/golang/go/wiki/CodeReviewComments -[godoc]: http://blog.golang.org/godoc-documenting-go-code - -## Tests - -- Always run [goimports][goimports] (which transitively calls `gofmt`) and `go vet` -- Use [table-driven tests][table-driven] wherever possible ([example][table-driven-example]) -- Use [travis][travis] to run unit/integration tests against the project repository ([example][travis-example]) -- Use [SemaphoreCI][semaphore] to run functional tests where possible ([example][semaphore-example]) -- Use [GoDebug][godebug] `pretty.Compare` to compare objects (structs, maps, slices, etc.) - -[godebug]: https://github.com/kylelemons/godebug/ -[goimports]: https://github.com/bradfitz/goimports -[table-driven]: https://github.com/golang/go/wiki/TableDrivenTests -[table-driven-example]: https://github.com/coreos/etcd/blob/35fddbc5d01f5e88bbc590c60f0b5e3ea8fa141b/raft/raft_paper_test.go#L186 -[travis]: https://travis-ci.org/ -[travis-example]: https://github.com/coreos/fleet/blob/master/.travis.yml -[semaphore]: https://semaphoreci.com/ -[semaphore-example]: https://github.com/coreos/rkt/blob/master/tests/README.md - -## Dependencies - -- Carefully consider adding dependencies to your project: Do you really need it? -- Manage third-party dependencies with [Glide][glide] and [glide-vc][glide-vc]. - -[glide]: https://github.com/Masterminds/glide -[glide-vc]: https://github.com/sgotti/glide-vc - -## Shared Code - -Idiomatic golang generally eschews creating generic utility packages in favour of implementing the necessary code as locally as possible to its use case. -In cases where generic, utility code makes sense, though, move it to `github.com/coreos/pkg`. -Use this repository as a first port of call when the need for generic code seems to arise. - -## Docker - -When creating Docker images from Go projects, use a combination of a `.godir` file and the `golang:onbuild` base image to produce the most simple Dockerfile for a Go project. -The `.godir` file must contain the import path of the package being written (i.e. etcd's .godir contains "github.com/coreos/etcd"). - -## Logging - -When in need of more sophisticated logging than the [stdlib log package][stdlib-log] provides, use the shared [CoreOS Log package][capnslog] (aka `capnslog`) - -[stdlib-log]: https://golang.org/pkg/log -[capnslog]: https://github.com/coreos/pkg/tree/master/capnslog - -## CLI - -In anything other than the most basic CLI cases (i.e. where the [stdlib flag package][stdlib-flag] suffices), use [Cobra][cobra] to construct command-line tools. - -[stdlib-flag]: https://golang.org/pkg/log -[cobra]: https://github.com/spf13/cobra - -## Development Tools - -- Use `gvm` to manage multiple versions of golang and multiple GOPATHs diff --git a/golang/build b/golang/build deleted file mode 100755 index d5fc78333..000000000 --- a/golang/build +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -e - -PROJ="newproj" -ORG_PATH="github.com/coreos" -REPO_PATH="${ORG_PATH}/${PROJ}" - -if [ ! -h gopath/src/${REPO_PATH} ]; then - mkdir -p gopath/src/${ORG_PATH} - ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255 -fi - -export GOBIN=${PWD}/bin -export GOPATH=${PWD}/gopath - -eval $(go env) - -echo "Building ${PROJ}d..." -go build -o bin/${PROJ}d ${REPO_PATH}/${PROJ}d diff --git a/golang/cover b/golang/cover deleted file mode 100755 index 4f77b7f5d..000000000 --- a/golang/cover +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -e -# -# Generate coverage HTML for a package -# e.g. PKG=./unit ./cover -# - -if [ -z "$PKG" ]; then - echo "cover only works with a single package, sorry" - exit 255 -fi - -COVEROUT="coverage" - -if ! [ -d "$COVEROUT" ]; then - mkdir "$COVEROUT" -fi - -# strip out slashes and dots -COVERPKG=${PKG//\//} -COVERPKG=${COVERPKG//./} - -# generate arg for "go test" -export COVER="-coverprofile ${COVEROUT}/${COVERPKG}.out" - -source ./test - -go tool cover -html=${COVEROUT}/${COVERPKG}.out diff --git a/golang/test b/golang/test deleted file mode 100755 index 007244d15..000000000 --- a/golang/test +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -e -# -# Run all tests (not including functional) -# ./test -# ./test -v -# -# Run tests for one package -# PKG=./foo ./test -# PKG=bar ./test -# - -# Invoke ./cover for HTML output -COVER=${COVER:-"-cover"} - -source ./build - -TESTABLE="foo bar" -FORMATTABLE="$TESTABLE baz" - -# user has not provided PKG override -if [ -z "$PKG" ]; then - TEST=$TESTABLE - FMT=$FORMATTABLE - -# user has provided PKG override -else - # strip out slashes and dots from PKG=./foo/ - TEST=${PKG//\//} - TEST=${TEST//./} - - # only run gofmt on packages provided by user - FMT="$TEST" -fi - -# split TEST into an array and prepend REPO_PATH to each local package -split=(${TEST// / }) -TEST=${split[@]/#/${REPO_PATH}/} - -echo "Running tests..." -go test ${COVER} $@ ${TEST} - -echo "Checking gofmt..." -fmtRes=$(gofmt -l $FMT) -if [ -n "${fmtRes}" ]; then - echo -e "gofmt checking failed:\n${fmtRes}" - exit 255 -fi - -echo "Checking govet..." -vetRes=$(go vet $TEST) -if [ -n "${vetRes}" ]; then - echo -e "govet checking failed:\n${vetRes}" - exit 255 -fi - -echo "Success"