mirror of
https://github.com/ysoftdevs/gardener-extension-shoot-fleet-agent.git
synced 2026-06-29 08:46:34 +02:00
Initial v1.0.0 commit
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
*.log
|
||||
.DS_Store
|
||||
doc
|
||||
tmp
|
||||
pkg
|
||||
*.gem
|
||||
*.pid
|
||||
coverage
|
||||
coverage.data
|
||||
build/*
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
.svn
|
||||
profile
|
||||
.console_history
|
||||
.sass-cache/*
|
||||
.rake_tasks~
|
||||
*.log.lck
|
||||
solr/
|
||||
.jhw-cache/
|
||||
jhw.*
|
||||
*.sublime*
|
||||
node_modules/
|
||||
dist/
|
||||
generated/
|
||||
.vendor/
|
||||
bin/*
|
||||
gin-bin
|
||||
.idea/
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Mark Bates
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
TAGS ?= ""
|
||||
GO_BIN ?= "go"
|
||||
|
||||
install:
|
||||
$(GO_BIN) install -tags ${TAGS} -v .
|
||||
make tidy
|
||||
|
||||
tidy:
|
||||
ifeq ($(GO111MODULE),on)
|
||||
$(GO_BIN) mod tidy
|
||||
else
|
||||
echo skipping go mod tidy
|
||||
endif
|
||||
|
||||
deps:
|
||||
$(GO_BIN) get -tags ${TAGS} -t ./...
|
||||
make tidy
|
||||
|
||||
build:
|
||||
$(GO_BIN) build -v .
|
||||
make tidy
|
||||
|
||||
test:
|
||||
$(GO_BIN) test -cover -tags ${TAGS} ./...
|
||||
make tidy
|
||||
|
||||
ci-deps:
|
||||
$(GO_BIN) get -tags ${TAGS} -t ./...
|
||||
|
||||
ci-test:
|
||||
$(GO_BIN) test -tags ${TAGS} -race ./...
|
||||
|
||||
lint:
|
||||
go get github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
golangci-lint run --enable-all
|
||||
make tidy
|
||||
|
||||
update:
|
||||
ifeq ($(GO111MODULE),on)
|
||||
rm go.*
|
||||
$(GO_BIN) mod init
|
||||
$(GO_BIN) mod tidy
|
||||
else
|
||||
$(GO_BIN) get -u -tags ${TAGS}
|
||||
endif
|
||||
make test
|
||||
make install
|
||||
make tidy
|
||||
|
||||
release-test:
|
||||
$(GO_BIN) test -tags ${TAGS} -race ./...
|
||||
make tidy
|
||||
|
||||
release:
|
||||
$(GO_BIN) get github.com/gobuffalo/release
|
||||
make tidy
|
||||
release -y -f version.go --skip-packr
|
||||
make tidy
|
||||
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
# github.com/markbates/errx Stands on the Shoulders of Giants
|
||||
|
||||
github.com/markbates/errx does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants, this project would not be possible. Please make sure to check them out and thank them for all of their hard work.
|
||||
|
||||
Thank you to the following **GIANTS**:
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
variables:
|
||||
GOBIN: "$(GOPATH)/bin" # Go binaries path
|
||||
GOPATH: "$(system.defaultWorkingDirectory)/gopath" # Go workspace path
|
||||
modulePath: "$(GOPATH)/src/github.com/$(build.repository.name)" # Path to the module"s code
|
||||
|
||||
jobs:
|
||||
- job: Windows
|
||||
pool:
|
||||
vmImage: "vs2017-win2016"
|
||||
strategy:
|
||||
matrix:
|
||||
go 1.10:
|
||||
go_version: "1.10"
|
||||
go 1.11 (on):
|
||||
go_version: "1.11.5"
|
||||
GO111MODULE: "on"
|
||||
go 1.11 (off):
|
||||
go_version: "1.11.5"
|
||||
GO111MODULE: "off"
|
||||
go 1.12 (on):
|
||||
go_version: "1.12"
|
||||
GO111MODULE: "on"
|
||||
go 1.12 (off):
|
||||
go_version: "1.12"
|
||||
GO111MODULE: "off"
|
||||
steps:
|
||||
- template: azure-tests.yml
|
||||
|
||||
- job: macOS
|
||||
pool:
|
||||
vmImage: "macOS-10.13"
|
||||
strategy:
|
||||
matrix:
|
||||
go 1.10:
|
||||
go_version: "1.10"
|
||||
go 1.11 (on):
|
||||
go_version: "1.11.5"
|
||||
GO111MODULE: "on"
|
||||
go 1.11 (off):
|
||||
go_version: "1.11.5"
|
||||
GO111MODULE: "off"
|
||||
go 1.12 (on):
|
||||
go_version: "1.12"
|
||||
GO111MODULE: "on"
|
||||
go 1.12 (off):
|
||||
go_version: "1.12"
|
||||
GO111MODULE: "off"
|
||||
steps:
|
||||
- template: azure-tests.yml
|
||||
|
||||
- job: Linux
|
||||
pool:
|
||||
vmImage: "ubuntu-16.04"
|
||||
strategy:
|
||||
matrix:
|
||||
go 1.10:
|
||||
go_version: "1.10"
|
||||
go 1.11 (on):
|
||||
go_version: "1.11.5"
|
||||
GO111MODULE: "on"
|
||||
go 1.11 (off):
|
||||
go_version: "1.11.5"
|
||||
GO111MODULE: "off"
|
||||
go 1.12 (on):
|
||||
go_version: "1.12"
|
||||
GO111MODULE: "on"
|
||||
go 1.12 (off):
|
||||
go_version: "1.12"
|
||||
GO111MODULE: "off"
|
||||
steps:
|
||||
- template: azure-tests.yml
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
steps:
|
||||
- task: GoTool@0
|
||||
inputs:
|
||||
version: $(go_version)
|
||||
- task: Bash@3
|
||||
inputs:
|
||||
targetType: inline
|
||||
script: |
|
||||
mkdir -p "$(GOBIN)"
|
||||
mkdir -p "$(GOPATH)/pkg"
|
||||
mkdir -p "$(modulePath)"
|
||||
shopt -s extglob
|
||||
mv !(gopath) "$(modulePath)"
|
||||
displayName: "Setup Go Workspace"
|
||||
- script: |
|
||||
go get -t -v ./...
|
||||
go test -race ./...
|
||||
workingDirectory: "$(modulePath)"
|
||||
displayName: "Tests"
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package errx
|
||||
|
||||
import "fmt"
|
||||
|
||||
// go2 errors
|
||||
type Wrapper interface {
|
||||
Unwrap() error
|
||||
}
|
||||
|
||||
// pkg/errors
|
||||
type Causer interface {
|
||||
Cause() error
|
||||
}
|
||||
|
||||
func Unwrap(err error) error {
|
||||
switch e := err.(type) {
|
||||
case Wrapper:
|
||||
return e.Unwrap()
|
||||
case Causer:
|
||||
return e.Cause()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
var Cause = Unwrap
|
||||
|
||||
func Wrap(err error, msg string) error {
|
||||
return wrapped{
|
||||
err: err,
|
||||
msg: msg,
|
||||
}
|
||||
}
|
||||
|
||||
type wrapped struct {
|
||||
err error
|
||||
msg string
|
||||
}
|
||||
|
||||
func (w wrapped) Error() string {
|
||||
return fmt.Sprintf("%s: %s", w.msg, w.err)
|
||||
}
|
||||
|
||||
func (w wrapped) Unwrap() error {
|
||||
return w.err
|
||||
}
|
||||
|
||||
func (w wrapped) Cause() error {
|
||||
return w.err
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module github.com/markbates/errx
|
||||
|
||||
go 1.12
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package errx
|
||||
|
||||
// Version of errx
|
||||
const Version = "v1.1.0"
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
*.log
|
||||
.DS_Store
|
||||
doc
|
||||
tmp
|
||||
pkg
|
||||
*.gem
|
||||
*.pid
|
||||
coverage
|
||||
coverage.data
|
||||
build/*
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
.svn
|
||||
profile
|
||||
.console_history
|
||||
.sass-cache/*
|
||||
.rake_tasks~
|
||||
*.log.lck
|
||||
solr/
|
||||
.jhw-cache/
|
||||
jhw.*
|
||||
*.sublime*
|
||||
node_modules/
|
||||
dist/
|
||||
generated/
|
||||
.vendor/
|
||||
bin/*
|
||||
gin-bin
|
||||
.idea/
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Mark Bates
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
TAGS ?= ""
|
||||
GO_BIN ?= "go"
|
||||
|
||||
install:
|
||||
$(GO_BIN) install -tags ${TAGS} -v .
|
||||
make tidy
|
||||
|
||||
tidy:
|
||||
ifeq ($(GO111MODULE),on)
|
||||
$(GO_BIN) mod tidy
|
||||
else
|
||||
echo skipping go mod tidy
|
||||
endif
|
||||
|
||||
deps:
|
||||
$(GO_BIN) get -tags ${TAGS} -t ./...
|
||||
make tidy
|
||||
|
||||
build:
|
||||
$(GO_BIN) build -v .
|
||||
make tidy
|
||||
|
||||
test:
|
||||
$(GO_BIN) test -cover -tags ${TAGS} ./...
|
||||
make tidy
|
||||
|
||||
ci-deps:
|
||||
$(GO_BIN) get -tags ${TAGS} -t ./...
|
||||
|
||||
ci-test:
|
||||
$(GO_BIN) test -tags ${TAGS} -race ./...
|
||||
|
||||
lint:
|
||||
go get github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
golangci-lint run --enable-all
|
||||
make tidy
|
||||
|
||||
update:
|
||||
ifeq ($(GO111MODULE),on)
|
||||
rm go.*
|
||||
$(GO_BIN) mod init
|
||||
$(GO_BIN) mod tidy
|
||||
else
|
||||
$(GO_BIN) get -u -tags ${TAGS}
|
||||
endif
|
||||
make test
|
||||
make install
|
||||
make tidy
|
||||
|
||||
release-test:
|
||||
$(GO_BIN) test -tags ${TAGS} -race ./...
|
||||
make tidy
|
||||
|
||||
release:
|
||||
$(GO_BIN) get github.com/gobuffalo/release
|
||||
make tidy
|
||||
release -y -f version.go --skip-packr
|
||||
make tidy
|
||||
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
# github.com/markbates/oncer Stands on the Shoulders of Giants
|
||||
|
||||
github.com/markbates/oncer does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants, this project would not be possible. Please make sure to check them out and thank them for all of their hard work.
|
||||
|
||||
Thank you to the following **GIANTS**:
|
||||
|
||||
|
||||
* [github.com/davecgh/go-spew](https://godoc.org/github.com/davecgh/go-spew)
|
||||
|
||||
* [github.com/stretchr/testify](https://godoc.org/github.com/stretchr/testify)
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
variables:
|
||||
GOBIN: "$(GOPATH)/bin" # Go binaries path
|
||||
GOPATH: "$(system.defaultWorkingDirectory)/gopath" # Go workspace path
|
||||
modulePath: "$(GOPATH)/src/github.com/$(build.repository.name)" # Path to the module"s code
|
||||
|
||||
jobs:
|
||||
- job: Windows
|
||||
pool:
|
||||
vmImage: "vs2017-win2016"
|
||||
strategy:
|
||||
matrix:
|
||||
go 1.11 (on):
|
||||
go_version: "1.11.11"
|
||||
GO111MODULE: "on"
|
||||
go 1.11 (off):
|
||||
go_version: "1.11.11"
|
||||
GO111MODULE: "off"
|
||||
go 1.12 (on):
|
||||
go_version: "1.12.6"
|
||||
GO111MODULE: "on"
|
||||
go 1.12 (off):
|
||||
go_version: "1.12.6"
|
||||
GO111MODULE: "off"
|
||||
steps:
|
||||
- template: azure-tests.yml
|
||||
|
||||
- job: macOS
|
||||
pool:
|
||||
vmImage: "macOS-10.13"
|
||||
strategy:
|
||||
matrix:
|
||||
go 1.11 (on):
|
||||
go_version: "1.11.11"
|
||||
GO111MODULE: "on"
|
||||
go 1.11 (off):
|
||||
go_version: "1.11.11"
|
||||
GO111MODULE: "off"
|
||||
go 1.12 (on):
|
||||
go_version: "1.12.6"
|
||||
GO111MODULE: "on"
|
||||
go 1.12 (off):
|
||||
go_version: "1.12.6"
|
||||
GO111MODULE: "off"
|
||||
steps:
|
||||
- template: azure-tests.yml
|
||||
|
||||
- job: Linux
|
||||
pool:
|
||||
vmImage: "ubuntu-16.04"
|
||||
strategy:
|
||||
matrix:
|
||||
go 1.11 (on):
|
||||
go_version: "1.11.11"
|
||||
GO111MODULE: "on"
|
||||
go 1.11 (off):
|
||||
go_version: "1.11.11"
|
||||
GO111MODULE: "off"
|
||||
go 1.12 (on):
|
||||
go_version: "1.12.6"
|
||||
GO111MODULE: "on"
|
||||
go 1.12 (off):
|
||||
go_version: "1.12.6"
|
||||
GO111MODULE: "off"
|
||||
steps:
|
||||
- template: azure-tests.yml
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
steps:
|
||||
- task: GoTool@0
|
||||
inputs:
|
||||
version: $(go_version)
|
||||
- task: Bash@3
|
||||
inputs:
|
||||
targetType: inline
|
||||
script: |
|
||||
mkdir -p "$(GOBIN)"
|
||||
mkdir -p "$(GOPATH)/pkg"
|
||||
mkdir -p "$(modulePath)"
|
||||
shopt -s extglob
|
||||
mv !(gopath) "$(modulePath)"
|
||||
displayName: "Setup Go Workspace"
|
||||
- script: |
|
||||
go get -t -v ./...
|
||||
go test -race ./...
|
||||
workingDirectory: "$(modulePath)"
|
||||
displayName: "Tests"
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package oncer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
const deprecated = "DEPRECATED"
|
||||
|
||||
var deprecationWriter io.Writer = os.Stdout
|
||||
|
||||
func Deprecate(depth int, name string, msg string) {
|
||||
Do(deprecated+name, func() {
|
||||
fmt.Fprintf(deprecationWriter, "[%s] %s has been deprecated.\n", deprecated, name)
|
||||
if len(msg) > 0 {
|
||||
fmt.Fprintf(deprecationWriter, "\t%s\n", msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
module github.com/markbates/oncer
|
||||
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/stretchr/testify v1.3.0
|
||||
)
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//+build !debug
|
||||
|
||||
package oncer
|
||||
|
||||
func log(name string, fn func()) func() {
|
||||
return fn
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//+build debug
|
||||
|
||||
package oncer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func log(name string, fn func()) func() {
|
||||
return func() {
|
||||
start := time.Now()
|
||||
if len(name) > 80 {
|
||||
name = name[(len(name) - 80):]
|
||||
}
|
||||
defer fmt.Println(name, time.Now().Sub(start))
|
||||
fn()
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package oncer
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
var onces = &sync.Map{}
|
||||
|
||||
func Do(name string, fn func()) {
|
||||
o, _ := onces.LoadOrStore(name, &sync.Once{})
|
||||
if once, ok := o.(*sync.Once); ok {
|
||||
once.Do(log(name, fn))
|
||||
}
|
||||
}
|
||||
|
||||
func Reset(names ...string) {
|
||||
if len(names) == 0 {
|
||||
onces = &sync.Map{}
|
||||
return
|
||||
}
|
||||
|
||||
for _, n := range names {
|
||||
onces.Delete(n)
|
||||
onces.Delete(deprecated + n)
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package oncer
|
||||
|
||||
// Version of oncer
|
||||
const Version = "v1.0.0"
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
*.log
|
||||
.DS_Store
|
||||
doc
|
||||
tmp
|
||||
pkg
|
||||
*.gem
|
||||
*.pid
|
||||
coverage
|
||||
coverage.data
|
||||
build/*
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
.svn
|
||||
profile
|
||||
.console_history
|
||||
.sass-cache/*
|
||||
.rake_tasks~
|
||||
*.log.lck
|
||||
solr/
|
||||
.jhw-cache/
|
||||
jhw.*
|
||||
*.sublime*
|
||||
node_modules/
|
||||
dist/
|
||||
generated/
|
||||
.vendor/
|
||||
bin/*
|
||||
gin-bin
|
||||
.idea/
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Enable": ["vet", "golint", "goimports", "deadcode", "gotype", "ineffassign", "misspell", "nakedret", "unconvert", "megacheck", "varcheck"]
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
language: go
|
||||
|
||||
sudo: false
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- go: "1.9.x"
|
||||
- go: "1.10.x"
|
||||
- go: "1.11.x"
|
||||
env:
|
||||
- GO111MODULE=off
|
||||
- go: "1.11.x"
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
- go: "tip"
|
||||
env:
|
||||
- GO111MODULE=off
|
||||
- go: "tip"
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
allow_failures:
|
||||
- go: "tip"
|
||||
|
||||
install: make deps
|
||||
|
||||
script: make ci-test
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Mark Bates
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
TAGS ?= "sqlite"
|
||||
GO_BIN ?= go
|
||||
|
||||
install:
|
||||
packr
|
||||
$(GO_BIN) install -tags ${TAGS} -v .
|
||||
make tidy
|
||||
|
||||
tidy:
|
||||
ifeq ($(GO111MODULE),on)
|
||||
$(GO_BIN) mod tidy
|
||||
else
|
||||
echo skipping go mod tidy
|
||||
endif
|
||||
|
||||
deps:
|
||||
$(GO_BIN) get github.com/gobuffalo/release
|
||||
$(GO_BIN) get github.com/gobuffalo/packr/packr
|
||||
$(GO_BIN) get -tags ${TAGS} -t ./...
|
||||
make tidy
|
||||
|
||||
build:
|
||||
packr
|
||||
$(GO_BIN) build -v .
|
||||
make tidy
|
||||
|
||||
test:
|
||||
packr
|
||||
$(GO_BIN) test -tags ${TAGS} ./...
|
||||
make tidy
|
||||
|
||||
ci-test:
|
||||
$(GO_BIN) test -tags ${TAGS} -race ./...
|
||||
make tidy
|
||||
|
||||
lint:
|
||||
gometalinter --vendor ./... --deadline=1m --skip=internal
|
||||
make tidy
|
||||
|
||||
update:
|
||||
$(GO_BIN) get -u -tags ${TAGS}
|
||||
make tidy
|
||||
packr
|
||||
make test
|
||||
make install
|
||||
make tidy
|
||||
|
||||
release-test:
|
||||
$(GO_BIN) test -tags ${TAGS} -race ./...
|
||||
make tidy
|
||||
|
||||
release:
|
||||
make tidy
|
||||
release -y -f version.go
|
||||
make tidy
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
module github.com/markbates/safe
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/testify v1.2.2
|
||||
)
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package safe
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Run the function safely knowing that if it panics
|
||||
// the panic will be caught and returned as an error
|
||||
func Run(fn func()) (err error) {
|
||||
return RunE(func() error {
|
||||
fn()
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Run the function safely knowing that if it panics
|
||||
// the panic will be caught and returned as an error
|
||||
func RunE(fn func() error) (err error) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if ex := recover(); ex != nil {
|
||||
if e, ok := ex.(error); ok {
|
||||
err = e
|
||||
return
|
||||
}
|
||||
err = errors.New(fmt.Sprint(ex))
|
||||
}
|
||||
}()
|
||||
return fn()
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
# github.com/markbates/safe Stands on the Shoulders of Giants
|
||||
|
||||
github.com/markbates/safe does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants this project would not be possible. Please make sure to check them out and thank them for all of their hard work.
|
||||
|
||||
Thank you to the following **GIANTS**:
|
||||
|
||||
|
||||
* [github.com/markbates/safe](https://godoc.org/github.com/markbates/safe)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package safe
|
||||
|
||||
const Version = "v1.0.1"
|
||||
Reference in New Issue
Block a user