aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Majewsky <stefan.majewsky@sap.com>2021-05-28 14:27:59 +0200
committerStefan Majewsky <stefan.majewsky@sap.com>2021-05-28 14:44:42 +0200
commit651cd5a02f2f9cce3d9f256bfa85553b8e17c3a0 (patch)
tree9bffcfa33d8ebb1b84aa69e4cc297d2b178cd4c1
parentf5332c147be25b138294151b3dd57ec4e0f28e26 (diff)
downloadgo-schwift-651cd5a02f2f9cce3d9f256bfa85553b8e17c3a0.tar.gz
use Go modules, update Makefile to my current conventions
-rw-r--r--.gitignore3
-rw-r--r--Makefile51
-rw-r--r--go.mod9
-rw-r--r--go.sum26
-rwxr-xr-xutil/gocovcat.go87
-rw-r--r--vendor/github.com/jpillora/longestcommon/README.md45
-rw-r--r--vendor/github.com/jpillora/longestcommon/lc.go82
-rw-r--r--vendor/github.com/jpillora/longestcommon/lc_test.go111
-rw-r--r--vendor/pins/github.com_jpillora_longestcommon1
-rw-r--r--vendor/skip/github.com_gophercloud_gophercloud0
10 files changed, 65 insertions, 350 deletions
diff --git a/.gitignore b/.gitignore
index 3f22794..df8085e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,3 @@
cover.out
cover.out.*
cover.html
-
-# vendoring
-.golangvend-cache/
diff --git a/Makefile b/Makefile
index 277d243..b955ad6 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,10 @@ help:
@echo ' make generate'
@echo ' make test'
+GO_BUILDFLAGS =
+GO_LDFLAGS =
+GO_TESTENV =
+
################################################################################
generate: generated.go
@@ -14,32 +18,37 @@ generate: generated.go
################################################################################
test: static-tests cover.html
-
-PKG = github.com/majewsky/schwift
-TESTPKGS = $(PKG) $(PKG)/tests # space-separated list of packages containing tests
-COVERPKGS = $(PKG),$(PKG)/gopherschwift # comma-separated list of packages for which to measure coverage
+ @printf "\e[1;32m>> All tests successful.\e[0m\n"
+
+# which packages to test with static checkers
+GO_ALLPKGS := $(shell go list ./... | grep -v '/util')
+# which files to test with static checkers (this contains a list of globs)
+GO_ALLFILES := $(addsuffix /*.go,$(patsubst $(shell go list .),.,$(GO_ALLPKGS)))
+# which packages to test with "go test"
+GO_TESTPKGS := $(shell go list -f '{{if .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -v '/util')
+# which packages to measure coverage for
+GO_COVERPKGS := $(shell go list ./... | grep -Ev '/util')
+# to get around weird Makefile syntax restrictions, we need variables containing a space and comma
+space := $(null) $(null)
+comma := ,
static-tests: FORCE
- @echo '>> gofmt...'
- @if s="$$(gofmt -s -l $$(find . -name \*.go) 2>/dev/null)" && test -n "$$s"; then echo "$$s"; false; fi
- @echo '>> golint...'
- @if s="$$(golint $(TESTPKGS) 2>/dev/null)" && test -n "$$s"; then echo "$$s"; false; fi
- @echo '>> govet...'
- @go vet $(TESTPKGS)
-
-cover.out.%: FORCE
- @echo '>> go test...'
- go test -covermode count -coverpkg $(COVERPKGS) -coverprofile $@ $(subst _,/,$*)
-cover.out: $(addprefix cover.out.,$(subst /,_,$(TESTPKGS)))
- util/gocovcat.go $^ > $@
+ @if ! hash golint 2>/dev/null; then printf "\e[1;36m>> Installing golint...\e[0m\n"; GO111MODULE=off go get -u golang.org/x/lint/golint; fi
+ @printf "\e[1;36m>> gofmt\e[0m\n"
+ @if s="$$(gofmt -s -d $(GO_ALLFILES) 2>/dev/null)" && test -n "$$s"; then echo "$$s"; false; fi
+ @printf "\e[1;36m>> golint\e[0m\n"
+ @if s="$$(golint $(GO_ALLPKGS) 2>/dev/null)" && test -n "$$s"; then echo "$$s"; false; fi
+ @printf "\e[1;36m>> go vet\e[0m\n"
+ @go vet $(GO_BUILDFLAGS) $(GO_ALLPKGS)
+
+cover.out: FORCE
+ @printf "\e[1;36m>> go test\e[0m\n"
+ @env $(GO_TESTENV) go test $(GO_BUILDFLAGS) -ldflags '-s -w $(GO_LDFLAGS)' -p 1 -coverprofile=$@ -covermode=count -coverpkg=$(subst $(space),$(comma),$(GO_COVERPKGS)) $(GO_TESTPKGS)
+
cover.html: cover.out
- @echo '>> rendering cover.html...'
+ @printf "\e[1;36m>> go tool cover > $@\e[0m\n"
@go tool cover -html=$< -o $@
################################################################################
-# vendoring by https://github.com/holocm/golangvend
-vendor: FORCE
- @golangvend
-
.PHONY: FORCE
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..59a323d
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,9 @@
+module github.com/majewsky/schwift
+
+go 1.16
+
+require (
+ github.com/gophercloud/gophercloud v0.17.0
+ github.com/gophercloud/utils v0.0.0-20210323225332-7b186010c04f
+ github.com/jpillora/longestcommon v0.0.0-20161227235612-adb9d91ee629
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..af36498
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,26 @@
+github.com/gophercloud/gophercloud v0.15.1-0.20210202035223-633d73521055/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4=
+github.com/gophercloud/gophercloud v0.17.0 h1:BgVw0saxyeHWH5us/SQe1ltp0GRnytjmOLXDA8pO77E=
+github.com/gophercloud/gophercloud v0.17.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4=
+github.com/gophercloud/utils v0.0.0-20210323225332-7b186010c04f h1:+SO5iEqu9QjNWL9TfAmOE5u0Uizv1T3jpBuMJfMOVJ0=
+github.com/gophercloud/utils v0.0.0-20210323225332-7b186010c04f/go.mod h1:wx8HMD8oQD0Ryhz6+6ykq75PJ79iPyEqYHfwZ4l7OsA=
+github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/jpillora/longestcommon v0.0.0-20161227235612-adb9d91ee629 h1:1dSBUfGlorLAua2CRx0zFN7kQsTpE2DQSmr7rrTNgY8=
+github.com/jpillora/longestcommon v0.0.0-20161227235612-adb9d91ee629/go.mod h1:mb5nS4uRANwOJSZj8rlCWAfAcGi72GGMIXx+xGOjA7M=
+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
diff --git a/util/gocovcat.go b/util/gocovcat.go
deleted file mode 100755
index bb03f87..0000000
--- a/util/gocovcat.go
+++ /dev/null
@@ -1,87 +0,0 @@
-///usr/bin/env go run "$0" "$@"; exit $?
-
-// Copyright 2017 Luke Shumaker <lukeshu@parabola.nu>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-// Command gocovcat combines multiple go cover runs, and prints the
-// result on stdout.
-package main
-
-import (
- "bufio"
- "fmt"
- "os"
- "sort"
- "strconv"
- "strings"
-)
-
-func handleErr(err error) {
- if err != nil {
- fmt.Fprintf(os.Stderr, "%v\n", err)
- os.Exit(1)
- }
-}
-
-func main() {
- modeBool := false
- blocks := map[string]int{}
- for _, filename := range os.Args[1:] {
- file, err := os.Open(filename)
- handleErr(err)
- buf := bufio.NewScanner(file)
- for buf.Scan() {
- line := buf.Text()
-
- if strings.HasPrefix(line, "mode: ") {
- m := strings.TrimPrefix(line, "mode: ")
- switch m {
- case "set":
- modeBool = true
- case "count", "atomic":
- // do nothing
- default:
- fmt.Fprintf(os.Stderr, "Unrecognized mode: %s\n", m)
- os.Exit(1)
- }
- } else {
- sp := strings.LastIndexByte(line, ' ')
- block := line[:sp]
- cntStr := line[sp+1:]
- cnt, err := strconv.Atoi(cntStr)
- handleErr(err)
- blocks[block] += cnt
- }
- }
- handleErr(buf.Err())
- }
- keys := make([]string, 0, len(blocks))
- for key := range blocks {
- keys = append(keys, key)
- }
- sort.Strings(keys)
- modeStr := "count"
- if modeBool {
- modeStr = "set"
- }
- fmt.Printf("mode: %s\n", modeStr)
- for _, block := range keys {
- cnt := blocks[block]
- if modeBool && cnt > 1 {
- cnt = 1
- }
- fmt.Printf("%s %d\n", block, cnt)
- }
-}
diff --git a/vendor/github.com/jpillora/longestcommon/README.md b/vendor/github.com/jpillora/longestcommon/README.md
deleted file mode 100644
index f32d865..0000000
--- a/vendor/github.com/jpillora/longestcommon/README.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# longestcommon
-
-Find the longest common prefix/suffix across of list of strings in Go (Golang). Runs in `O(n)`.
-
-[![GoDoc](https://godoc.org/github.com/jpillora/longestcommon?status.svg)](https://godoc.org/github.com/jpillora/longestcommon) [![Circle CI](https://circleci.com/gh/jpillora/longestcommon.svg?style=shield)](https://circleci.com/gh/jpillora/longestcommon)
-
-### Install
-
-```
-$ go get -v github.com/jpillora/longestcommon
-```
-
-### Usage
-
-``` go
-longestcommon.Prefix([]string{"flower","flow","fleet"}) //"fl"
-longestcommon.Suffix([]string{"flower","power","lower"}) //"ower"
-```
-
-### TODO
-
-* Include [Longest Common Subsequence](https://github.com/jpillora/lcs) with its TODOs completed
-
-#### MIT License
-
-Copyright © 2015 Jaime Pillora &lt;dev@jpillora.com&gt;
-
-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.
diff --git a/vendor/github.com/jpillora/longestcommon/lc.go b/vendor/github.com/jpillora/longestcommon/lc.go
deleted file mode 100644
index 788a7a6..0000000
--- a/vendor/github.com/jpillora/longestcommon/lc.go
+++ /dev/null
@@ -1,82 +0,0 @@
-package longestcommon
-
-import "strings"
-
-//TrimPrefix removes the longest common prefix from all provided strings
-func TrimPrefix(strs []string) {
- p := Prefix(strs)
- if p == "" {
- return
- }
- for i, s := range strs {
- strs[i] = strings.TrimPrefix(s, p)
- }
-}
-
-//TrimSuffix removes the longest common suffix from all provided strings
-func TrimSuffix(strs []string) {
- p := Suffix(strs)
- if p == "" {
- return
- }
- for i, s := range strs {
- strs[i] = strings.TrimSuffix(s, p)
- }
-}
-
-//Prefix returns the longest common prefix of the provided strings
-func Prefix(strs []string) string {
- return longestCommonXfix(strs, true)
-}
-
-//Suffix returns the longest common suffix of the provided strings
-func Suffix(strs []string) string {
- return longestCommonXfix(strs, false)
-}
-
-func longestCommonXfix(strs []string, pre bool) string {
- //short-circuit empty list
- if len(strs) == 0 {
- return ""
- }
- xfix := strs[0]
- //short-circuit single-element list
- if len(strs) == 1 {
- return xfix
- }
- //compare first to rest
- for _, str := range strs[1:] {
- xfixl := len(xfix)
- strl := len(str)
- //short-circuit empty strings
- if xfixl == 0 || strl == 0 {
- return ""
- }
- //maximum possible length
- maxl := xfixl
- if strl < maxl {
- maxl = strl
- }
- //compare letters
- if pre {
- //prefix, iterate left to right
- for i := 0; i < maxl; i++ {
- if xfix[i] != str[i] {
- xfix = xfix[:i]
- break
- }
- }
- } else {
- //suffix, iternate right to left
- for i := 0; i < maxl; i++ {
- xi := xfixl - i - 1
- si := strl - i - 1
- if xfix[xi] != str[si] {
- xfix = xfix[xi+1:]
- break
- }
- }
- }
- }
- return xfix
-}
diff --git a/vendor/github.com/jpillora/longestcommon/lc_test.go b/vendor/github.com/jpillora/longestcommon/lc_test.go
deleted file mode 100644
index 136e3ff..0000000
--- a/vendor/github.com/jpillora/longestcommon/lc_test.go
+++ /dev/null
@@ -1,111 +0,0 @@
-package longestcommon
-
-import (
- "strings"
- "testing"
-)
-
-func doTest(t *testing.T, lines, pre, suf string) {
- strs := []string{}
- if lines != "" {
- strs = strings.Split(lines, "\n")
- }
- p := Prefix(strs)
- if p != pre {
- t.Fatalf("fail: expected prefix '%s', got '%s'", pre, p)
- }
- s := Suffix(strs)
- if s != suf {
- t.Fatalf("fail: expected suffix '%s', got '%s'", suf, s)
- }
-}
-
-func TestXFix1(t *testing.T) {
- doTest(t, ``, "", "")
-}
-
-func TestXFix2(t *testing.T) {
- doTest(t, `single`, "single", "single")
-}
-
-func TestXFix3(t *testing.T) {
- doTest(t, "single\ndouble", "", "le")
-}
-
-func TestXFix4(t *testing.T) {
- doTest(t, "flower\nflow\nfleet", "fl", "")
-}
-
-func TestXFix5(t *testing.T) {
- doTest(t, `My Awesome Album - 01.mp3
-My Awesome Album - 11.mp3
-My Awesome Album - 03.mp3
-My Awesome Album - 04.mp3
-My Awesome Album - 05.mp3
-My Awesome Album - 06.mp3
-My Awesome Album - 07.mp3
-My Awesome Album - 08.mp3
-My Awesome Album - 09.mp3
-My Awesome Album - 10.mp3
-My Awesome Album - 11.mp3
-My Awesome Album - 12.mp3
-My Awesome Album - 13.mp3
-My Awesome Album - 14.mp3
-My Awesome Album - 15.mp3
-My Awesome Album - 16.mp3
-My Awesome Album - 17.mp3
-My Awesome Album - 18.mp3
-My Awesome Album - 19.mp3
-My Awesome Album - 20.mp3
-My Awesome Album - 21.mp3
-My Awesome Album - 22.mp3
-My Awesome Album - 23.mp3
-My Awesome Album - 24.mp3
-My Awesome Album - 25.mp3
-My Awesome Album - 26.mp3
-My Awesome Album - 27.mp3
-My Awesome Album - 28.mp3
-My Awesome Album - 29.mp3
-My Awesome Album - 30.mp3
-My Awesome Album - 31.mp3
-My Awesome Album - 32.mp3
-My Awesome Album - 33.mp3
-My Awesome Album - 34.mp3
-My Awesome Album - 35.mp3
-My Awesome Album - 36.mp3
-My Awesome Album - 37.mp3
-My Awesome Album - 38.mp3
-My Awesome Album - 39.mp3`, "My Awesome Album - ", ".mp3")
-}
-
-func TestTrimPrefix1(t *testing.T) {
- strs := []string{"flower", "flow", "fleet"}
- TrimPrefix(strs)
- if strs[0] != "ower" {
- t.Fatalf("fail: expected result string to be 'ower', got '%s'", strs[0])
- }
-}
-
-func TestTrimPrefix2(t *testing.T) {
- strs := []string{"flower", "tree"}
- TrimPrefix(strs) //no common prefix
- if strs[0] != "flower" {
- t.Fatalf("fail: expected result string to be 'flower', got '%s'", strs[0])
- }
-}
-
-func TestTrimSuffix1(t *testing.T) {
- strs := []string{"flower", "power"}
- TrimSuffix(strs)
- if strs[0] != "fl" {
- t.Fatalf("fail: expected result string to be 'fl', got '%s'", strs[0])
- }
-}
-
-func TestTrimSuffix2(t *testing.T) {
- strs := []string{"flower", "tree"}
- TrimSuffix(strs) //no common suffix
- if strs[0] != "flower" {
- t.Fatalf("fail: expected result string to be 'flower', got '%s'", strs[0])
- }
-}
diff --git a/vendor/pins/github.com_jpillora_longestcommon b/vendor/pins/github.com_jpillora_longestcommon
deleted file mode 100644
index 28c3fec..0000000
--- a/vendor/pins/github.com_jpillora_longestcommon
+++ /dev/null
@@ -1 +0,0 @@
-adb9d91ee629dd8304c9f9d7c91977b9d7e61a35
diff --git a/vendor/skip/github.com_gophercloud_gophercloud b/vendor/skip/github.com_gophercloud_gophercloud
deleted file mode 100644
index e69de29..0000000
--- a/vendor/skip/github.com_gophercloud_gophercloud
+++ /dev/null