Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a109e5a
Showing
7 changed files
with
119 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Makefile linguist-vendored |
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,9 @@ | ||
.project | ||
.classpath | ||
.idea | ||
.cache | ||
.DS_Store | ||
*.im? | ||
target | ||
work | ||
bin/ |
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,68 @@ | ||
SHELL := /bin/bash | ||
GO := GO15VENDOREXPERIMENT=1 go | ||
NAME := REPLACE_ME_APP_NAME | ||
OS := $(shell uname) | ||
MAIN_GO := main.go | ||
ROOT_PACKAGE := $(GIT_PROVIDER)/$(ORG)/$(NAME) | ||
GO_VERSION := $(shell $(GO) version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/') | ||
PACKAGE_DIRS := $(shell $(GO) list ./... | grep -v /vendor/) | ||
PKGS := $(shell go list ./... | grep -v /vendor | grep -v generated) | ||
PKGS := $(subst :,_,$(PKGS)) | ||
BUILDFLAGS := '' | ||
CGO_ENABLED = 0 | ||
VENDOR_DIR=vendor | ||
|
||
all: build | ||
|
||
check: fmt build test | ||
|
||
build: | ||
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO) | ||
|
||
test: | ||
CGO_ENABLED=$(CGO_ENABLED) $(GO) test $(PACKAGE_DIRS) -test.v | ||
|
||
full: $(PKGS) | ||
|
||
install: | ||
GOBIN=${GOPATH}/bin $(GO) install -ldflags $(BUILDFLAGS) $(MAIN_GO) | ||
|
||
fmt: | ||
@FORMATTED=`$(GO) fmt $(PACKAGE_DIRS)` | ||
@([[ ! -z "$(FORMATTED)" ]] && printf "Fixed unformatted files:\n$(FORMATTED)") || true | ||
|
||
clean: | ||
rm -rf build release | ||
|
||
linux: | ||
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 $(GO) build -ldflags $(BUILDFLAGS) -o bin/$(NAME) $(MAIN_GO) | ||
|
||
.PHONY: release clean | ||
|
||
FGT := $(GOPATH)/bin/fgt | ||
$(FGT): | ||
go get github.com/GeertJohan/fgt | ||
|
||
GOLINT := $(GOPATH)/bin/golint | ||
$(GOLINT): | ||
go get github.com/golang/lint/golint | ||
|
||
$(PKGS): $(GOLINT) $(FGT) | ||
@echo "LINTING" | ||
@$(FGT) $(GOLINT) $(GOPATH)/src/$@/*.go | ||
@echo "VETTING" | ||
@go vet -v $@ | ||
@echo "TESTING" | ||
@go test -v $@ | ||
|
||
.PHONY: lint | ||
lint: vendor | $(PKGS) $(GOLINT) # ❷ | ||
@cd $(BASE) && ret=0 && for pkg in $(PKGS); do \ | ||
test -z "$$($(GOLINT) $$pkg | tee /dev/stderr)" || ret=1 ; \ | ||
done ; exit $$ret | ||
|
||
watch: | ||
reflex -r "\.go$" -R "vendor.*" make skaffold-run | ||
|
||
skaffold-run: build | ||
skaffold run -p dev |
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 @@ | ||
# golang-http |
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,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
export APP="$1" | ||
echo "curling URL $APP in a loop..." | ||
|
||
while true | ||
do | ||
curl $APP | ||
sleep 2 | ||
done |
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,26 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
func handler(w http.ResponseWriter, r *http.Request) { | ||
title := "Jenkins X golang http example" | ||
|
||
from := "" | ||
if r.URL != nil { | ||
from = r.URL.String() | ||
} | ||
if from != "/favicon.ico" { | ||
log.Printf("title: %s\n", title) | ||
} | ||
|
||
fmt.Fprintf(w, "Hello from: "+title+"\n") | ||
} | ||
|
||
func main() { | ||
http.HandleFunc("/", handler) | ||
http.ListenAndServe(":8080", nil) | ||
} |
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,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
make skaffold-run | ||
reflex -r "\.go$" -R "vendor.*" make skaffold-run |