This repository has been archived by the owner on Dec 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHORE: Start correcting code problems (#39)
* Use go channels to hopefully not print before server dies This PR does the following: - Setup and block on the done channel - Print message after spinning out the go server (the server dies if any exception happens), so we should be able to rely on seeing this message now - Block for the connectws() consumers Signed-off-by: Brandon Schneider <[email protected]> * Also log to file when we listen Signed-off-by: Brandon Schneider <[email protected]> * We should also log to file any errors and fatally exit Signed-off-by: Brandon Schneider <[email protected]> * CHORE: Start correcting code problems This also institutes a lint before we build. Along with typos. Signed-off-by: Brandon Schneider <[email protected]> * Get these deps when we make and split out dev/release building Signed-off-by: Brandon Schneider <[email protected]> * Let’s add install as well Signed-off-by: Brandon Schneider <[email protected]> * Export PATH to include GOPATH for our installed deps Signed-off-by: Brandon Schneider <[email protected]> * Allow running things from GOPATH expanded out to use bin/ and tossed into PATH at runtime * Include full PATH * Switch to Mage This is easier to maintain. Signed-off-by: Brandon Schneider <[email protected]> * Typo and fmt Signed-off-by: Brandon Schneider <[email protected]> * Add helper Makefile to run go run bootstrap.go targets for common use cases, for us old-school folks who don't use mage * Format Signed-off-by: Brandon Schneider <[email protected]>
- Loading branch information
Brandon Schneider
authored
May 13, 2019
1 parent
9a75da8
commit 9ef174d
Showing
11 changed files
with
176 additions
and
52 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,13 @@ | ||
# Go parameters | ||
GOCMD=go | ||
GOBUILD=$(GOCMD) build | ||
GOCLEAN=$(GOCMD) clean | ||
GOTEST=$(GOCMD) test | ||
GOGET=$(GOCMD) get | ||
BINARY_NAME=sysup | ||
|
||
# We will add test later | ||
all: format build | ||
all: build | ||
|
||
build: | ||
$(GOBUILD) -o $(BINARY_NAME) -v | ||
format: | ||
$(GOCMD) fmt ./... | ||
test: | ||
$(GOTEST) -v ./... | ||
clean: | ||
$(GOCLEAN) | ||
rm -f $(BINARY_NAME) | ||
run: | ||
$(GOBUILD) -o $(BINARY_NAME) -v ./... | ||
./$(BINARY_NAME) | ||
go run bootstrap.go build | ||
|
||
dev: | ||
go run bootstrap.go dev | ||
|
||
lint: | ||
go run bootstrap.go lint | ||
|
||
install: | ||
go run bootstrap.go install |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//+build bootstrap | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/magefile/mage/mage" | ||
"os" | ||
) | ||
|
||
func main() { | ||
os.Exit(mage.Main()) | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,27 @@ | ||
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= | ||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= | ||
github.com/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835 h1:roDmqJ4Qes7hrDOsWsMCce0vQHz3xiMPjJ9m4c2eeNs= | ||
github.com/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835/go.mod h1:BjL/N0+C+j9uNX+1xcNuM9vdSIcXCZrQZUYbXOFbgN8= | ||
github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc h1:cJlkeAx1QYgO5N80aF5xRGstVsRQwgLR7uA2FnP1ZjY= | ||
github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= | ||
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= | ||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= | ||
github.com/magefile/mage v1.8.0 h1:mzL+xIopvPURVBwHG9A50JcjBO+xV3b5iZ7khFRI+5E= | ||
github.com/magefile/mage v1.8.0/go.mod h1:IUDi13rsHje59lecXokTfGX0QIzO45uVPlXnJYsXepA= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI= | ||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= | ||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= | ||
golang.org/x/tools v0.0.0-20190509153222-73554e0f7805 h1:1ufBXAsTpUhSmmPXEEs5PrGQSfnBhsjAd2SmVhp9xrY= | ||
golang.org/x/tools v0.0.0-20190509153222-73554e0f7805/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//+build mage | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/magefile/mage/mg" | ||
"github.com/magefile/mage/sh" | ||
"log" | ||
) | ||
|
||
// TODO: Use Test() later | ||
|
||
// Uses go fmt to format all our modules | ||
func Format() { | ||
log.Println("Running format") | ||
|
||
sh.RunV("go", "fmt", "./...") | ||
} | ||
|
||
// Installs our formatting deps | ||
func InstallDeps() { | ||
log.Println("Installing deps") | ||
sh.Run( | ||
"go", "get", "github.com/fzipp/gocyclo", | ||
"github.com/gordonklaus/ineffassign", "github.com/client9/misspell", | ||
"golang.org/x/lint/golint", | ||
) | ||
} | ||
|
||
// Runs the linting process | ||
func Lint() { | ||
log.Println("Running lint") | ||
sh.RunV("go", "vet", "./...") | ||
sh.RunV( | ||
"gocyclo", "-over", "15", "pkg", "logger", "trains", "update", | ||
"utils", "ws", "defines", "client", | ||
) | ||
sh.RunV("golint", "./...") | ||
sh.RunV("ineffassign", "./") | ||
sh.RunV("misspell", "-w", "./") | ||
} | ||
|
||
// Cleans sysups binary up | ||
func Clean() { | ||
log.Println("Running clean") | ||
sh.RunV("go", "clean") | ||
sh.RunV("rm", "-f", "./sysup") | ||
} | ||
|
||
// Builds sysup and run it from this directory | ||
func Run() { | ||
log.Println("Running run") | ||
mg.Deps(Build) | ||
sh.Run("./sysup") | ||
} | ||
|
||
// Installs sysup to GOPATH | ||
func Install() { | ||
log.Println("Running install") | ||
sh.RunV("go", "install") | ||
} | ||
|
||
// Run our tests (nonfunctional) | ||
func Test() { | ||
log.Println("Running test") | ||
sh.RunV("go", "test", "-v", "./...") | ||
} | ||
|
||
// Builds sysup and install it | ||
func All() { | ||
log.Println("Making all") | ||
mg.Deps(Build, Install) | ||
} | ||
|
||
// Builds sysup | ||
func Build() { | ||
log.Println("Making build") | ||
sh.RunV("go", "build", "-o", "sysup", "-v") | ||
} | ||
|
||
// Standard development build process (format, install deps, lint, build) | ||
func Dev() { | ||
log.Println("Making dev") | ||
mg.Deps(Format, InstallDeps, Lint, Build) | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.