From bc1a272e755dde24cdc8faa9595bac8272f6a76b Mon Sep 17 00:00:00 2001 From: Jaime Pillora Date: Wed, 29 Dec 2021 23:18:00 +0000 Subject: [PATCH 1/5] switch to go mod, switch to github actions --- .circleci/config.yml | 61 -------- .github/goreleaser.yml | 32 ++++ .github/workflows/ci.yml | 46 ++++++ Godeps/Godeps.json | 19 --- Godeps/Readme | 5 - go.mod | 8 + go.sum | 4 + start_test.go | 8 +- .../daviddengcn/go-colortext/.gitignore | 22 --- .../daviddengcn/go-colortext/LICENSE | 27 ---- .../daviddengcn/go-colortext/README.md | 21 --- .../github.com/daviddengcn/go-colortext/ct.go | 47 ------ .../daviddengcn/go-colortext/ct_ansi.go | 35 ----- .../daviddengcn/go-colortext/ct_win.go | 139 ------------------ vendor/github.com/subosito/gotenv/.env | 1 - vendor/github.com/subosito/gotenv/.gitignore | 2 - vendor/github.com/subosito/gotenv/LICENSE | 21 --- vendor/github.com/subosito/gotenv/README.md | 102 ------------- vendor/github.com/subosito/gotenv/gotenv.go | 119 --------------- 19 files changed, 94 insertions(+), 625 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/goreleaser.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 Godeps/Godeps.json delete mode 100644 Godeps/Readme create mode 100644 go.mod create mode 100644 go.sum delete mode 100644 vendor/github.com/daviddengcn/go-colortext/.gitignore delete mode 100644 vendor/github.com/daviddengcn/go-colortext/LICENSE delete mode 100644 vendor/github.com/daviddengcn/go-colortext/README.md delete mode 100644 vendor/github.com/daviddengcn/go-colortext/ct.go delete mode 100644 vendor/github.com/daviddengcn/go-colortext/ct_ansi.go delete mode 100644 vendor/github.com/daviddengcn/go-colortext/ct_win.go delete mode 100644 vendor/github.com/subosito/gotenv/.env delete mode 100644 vendor/github.com/subosito/gotenv/.gitignore delete mode 100644 vendor/github.com/subosito/gotenv/LICENSE delete mode 100644 vendor/github.com/subosito/gotenv/README.md delete mode 100644 vendor/github.com/subosito/gotenv/gotenv.go diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 5175d2a..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,61 +0,0 @@ -# Golang CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/language-go/ for more details -version: 2 -jobs: - build: - docker: - # specify the version - - image: circleci/golang:1.9 - - working_directory: /go/src/github.com/ddollar/forego - - environment: - TEST_RESULTS: /tmp/test-results - - steps: - - checkout - - run: go get github.com/daviddengcn/go-colortext - - run: go get github.com/subosito/gotenv - - # For capturing test results - - run: go get github.com/jstemmer/go-junit-report - - run: mkdir -p $TEST_RESULTS - - # specify any bash command here prefixed with `run: ` - - run: - name: Run unit tests - command: | - trap "go-junit-report <${TEST_RESULTS}/forego-tests.log > ${TEST_RESULTS}/forego-tests-report.xml" EXIT - make test | tee ${TEST_RESULTS}/forego-tests.log - - - store_artifacts: - path: /tmp/test-results - destination: raw-test-output - - - store_test_results: - path: /tmp/test-results - release: - docker: - - image: circleci/golang:1.9 - - working_directory: /go/src/github.com/ddollar/forego - - steps: - - checkout - - run: go get github.com/daviddengcn/go-colortext - - run: go get github.com/subosito/gotenv - - - run: make release - -workflows: - version: 2 - deployment: - jobs: - - build - - release: - requires: - - build - filters: - branches: - only: master diff --git a/.github/goreleaser.yml b/.github/goreleaser.yml new file mode 100644 index 0000000..82d9f61 --- /dev/null +++ b/.github/goreleaser.yml @@ -0,0 +1,32 @@ +# test this file with +# goreleaser --skip-publish --rm-dist --config goreleaser.yml +builds: + - main: ./main.go + env: + - CGO_ENABLED=0 + ldflags: + - -s -w -X main.version={{.Version}} + goos: + - linux + - darwin + - windows + goarch: + - 386 + - amd64 + - arm + - arm64 + goarm: + - 6 + - 7 +archives: + - format: gz + files: + - none* +release: + prerelease: auto +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..eb0f9ab --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +on: [push, pull_request] +name: CI +jobs: + # ================ + # TEST JOB + # runs on every push and PR + # runs 2x3 times (see matrix) + # ================ + test: + name: Test + strategy: + matrix: + go-version: [1.16.x, 1.17.x] + platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v2 + - name: Build + run: go build -v . + - name: Test + run: go test -v ./... + # ================ + # RELEASE JOB + # runs after a success test + # only runs on push "v*" tag + # ================ + release: + name: Release + needs: test + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: goreleaser + if: success() + uses: docker://goreleaser/goreleaser:latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: release --config .github/goreleaser.yml diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json deleted file mode 100644 index 1cc516a..0000000 --- a/Godeps/Godeps.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "ImportPath": "github.com/ddollar/forego", - "GoVersion": "go1.6", - "GodepVersion": "v61", - "Packages": [ - "./..." - ], - "Deps": [ - { - "ImportPath": "github.com/daviddengcn/go-colortext", - "Rev": "3b18c8575a432453d41fdafb340099fff5bba2f7" - }, - { - "ImportPath": "github.com/subosito/gotenv", - "Comment": "v0.1.0", - "Rev": "a37a0e8fb3298354bf97daad07b38feb2d0fa263" - } - ] -} diff --git a/Godeps/Readme b/Godeps/Readme deleted file mode 100644 index 4cdaa53..0000000 --- a/Godeps/Readme +++ /dev/null @@ -1,5 +0,0 @@ -This directory tree is generated automatically by godep. - -Please do not edit. - -See https://github.com/tools/godep for more information. diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1d759ac --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/ddollar/forego + +go 1.17 + +require ( + github.com/daviddengcn/go-colortext v0.0.0-20150719211842-3b18c8575a43 + github.com/subosito/gotenv v0.1.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c30bc18 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +github.com/daviddengcn/go-colortext v0.0.0-20150719211842-3b18c8575a43 h1:WOjNHsegRa6W+i7+V0g9GlGTKj5c2CzvENZBOYLYxMQ= +github.com/daviddengcn/go-colortext v0.0.0-20150719211842-3b18c8575a43/go.mod h1:dv4zxwHi5C/8AeI+4gX4dCWOIvNi7I6JCSX0HvlKPgE= +github.com/subosito/gotenv v0.1.0 h1:qrPfMw+dkLrA77HtD6S3ppWB9JjV8jhKMmeSpnuvd3Q= +github.com/subosito/gotenv v0.1.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= diff --git a/start_test.go b/start_test.go index b57ca5f..8982588 100644 --- a/start_test.go +++ b/start_test.go @@ -123,7 +123,7 @@ func TestPortFromEnv(t *testing.T) { os.Setenv("PORT", "4000") port, err = basePort(env) if err != nil { - t.Fatal("Can not get port: %s", err) + t.Fatalf("Can not get port: %s", err) } if port != 4000 { t.Fatal("Base port should be 4000") @@ -162,14 +162,14 @@ func TestConfigBeOverrideByForegoFile(t *testing.T) { } if port != 15000 { - t.Fatal("port should be 15000, got %d", port) + t.Fatalf("port should be 15000, got %d", port) } if concurrency != "foo=2,bar=3" { - t.Fatal("concurrency should be 'foo=2,bar=3', got %s", concurrency) + t.Fatalf("concurrency should be 'foo=2,bar=3', got %s", concurrency) } if gracetime != 30 { - t.Fatal("gracetime should be 3, got %d", gracetime) + t.Fatalf("gracetime should be 3, got %d", gracetime) } } diff --git a/vendor/github.com/daviddengcn/go-colortext/.gitignore b/vendor/github.com/daviddengcn/go-colortext/.gitignore deleted file mode 100644 index 0026861..0000000 --- a/vendor/github.com/daviddengcn/go-colortext/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe diff --git a/vendor/github.com/daviddengcn/go-colortext/LICENSE b/vendor/github.com/daviddengcn/go-colortext/LICENSE deleted file mode 100644 index 974ec42..0000000 --- a/vendor/github.com/daviddengcn/go-colortext/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2015, David Deng -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of go-colortext nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/daviddengcn/go-colortext/README.md b/vendor/github.com/daviddengcn/go-colortext/README.md deleted file mode 100644 index 6e140f1..0000000 --- a/vendor/github.com/daviddengcn/go-colortext/README.md +++ /dev/null @@ -1,21 +0,0 @@ -go-colortext package [![GoSearch](http://go-search.org/badge?id=github.com%2Fdaviddengcn%2Fgo-colortext)](http://go-search.org/view?id=github.com%2Fdaviddengcn%2Fgo-colortext) -==================== - -This is a package to change the color of the text and background in the console, working both under Windows and other systems. - -Under Windows, the console APIs are used. Otherwise, ANSI texts are output. - -Docs: http://godoc.org/github.com/daviddengcn/go-colortext ([packages that import ct](http://go-search.org/view?id=github.com%2fdaviddengcn%2fgo-colortext)) - -Usage: -```go -Foreground(Green, false) -fmt.Println("Green text starts here...") -ChangeColor(Red, true, White, false) -fmt.Println(...) -ResetColor() -``` - -LICENSE -======= -BSD license diff --git a/vendor/github.com/daviddengcn/go-colortext/ct.go b/vendor/github.com/daviddengcn/go-colortext/ct.go deleted file mode 100644 index 4acfaac..0000000 --- a/vendor/github.com/daviddengcn/go-colortext/ct.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -ct package provides functions to change the color of console text. - -Under windows platform, the Console api is used. Under other systems, ANSI text mode is used. -*/ -package ct - -// Color is the type of color to be set. -type Color int - -const ( - // No change of color - None = Color(iota) - Black - Red - Green - Yellow - Blue - Magenta - Cyan - White -) - -/* -ResetColor resets the foreground and background to original colors -*/ -func ResetColor() { - resetColor() -} - -// ChangeColor sets the foreground and background colors. If the value of the color is None, -// the corresponding color keeps unchanged. -// If fgBright or bgBright is set true, corresponding color use bright color. bgBright may be -// ignored in some OS environment. -func ChangeColor(fg Color, fgBright bool, bg Color, bgBright bool) { - changeColor(fg, fgBright, bg, bgBright) -} - -// Foreground changes the foreground color. -func Foreground(cl Color, bright bool) { - ChangeColor(cl, bright, None, false) -} - -// Background changes the background color. -func Background(cl Color, bright bool) { - ChangeColor(None, false, cl, bright) -} diff --git a/vendor/github.com/daviddengcn/go-colortext/ct_ansi.go b/vendor/github.com/daviddengcn/go-colortext/ct_ansi.go deleted file mode 100644 index 6b0c5bc..0000000 --- a/vendor/github.com/daviddengcn/go-colortext/ct_ansi.go +++ /dev/null @@ -1,35 +0,0 @@ -// +build !windows - -package ct - -import ( - "fmt" -) - -func resetColor() { - fmt.Print("\x1b[0m") -} - -func changeColor(fg Color, fgBright bool, bg Color, bgBright bool) { - if fg == None && bg == None { - return - } // if - - s := "" - if fg != None { - s = fmt.Sprintf("%s%d", s, 30+(int)(fg-Black)) - if fgBright { - s += ";1" - } // if - } // if - - if bg != None { - if s != "" { - s += ";" - } // if - s = fmt.Sprintf("%s%d", s, 40+(int)(bg-Black)) - } // if - - s = "\x1b[0;" + s + "m" - fmt.Print(s) -} diff --git a/vendor/github.com/daviddengcn/go-colortext/ct_win.go b/vendor/github.com/daviddengcn/go-colortext/ct_win.go deleted file mode 100644 index 6b41644..0000000 --- a/vendor/github.com/daviddengcn/go-colortext/ct_win.go +++ /dev/null @@ -1,139 +0,0 @@ -// +build windows - -package ct - -import ( - "syscall" - "unsafe" -) - -var fg_colors = []uint16{ - 0, - 0, - foreground_red, - foreground_green, - foreground_red | foreground_green, - foreground_blue, - foreground_red | foreground_blue, - foreground_green | foreground_blue, - foreground_red | foreground_green | foreground_blue} - -var bg_colors = []uint16{ - 0, - 0, - background_red, - background_green, - background_red | background_green, - background_blue, - background_red | background_blue, - background_green | background_blue, - background_red | background_green | background_blue} - -const ( - foreground_blue = uint16(0x0001) - foreground_green = uint16(0x0002) - foreground_red = uint16(0x0004) - foreground_intensity = uint16(0x0008) - background_blue = uint16(0x0010) - background_green = uint16(0x0020) - background_red = uint16(0x0040) - background_intensity = uint16(0x0080) - - foreground_mask = foreground_blue | foreground_green | foreground_red | foreground_intensity - background_mask = background_blue | background_green | background_red | background_intensity -) - -var ( - kernel32 = syscall.NewLazyDLL("kernel32.dll") - - procGetStdHandle = kernel32.NewProc("GetStdHandle") - procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute") - procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") - - hStdout uintptr - initScreenInfo *console_screen_buffer_info -) - -func setConsoleTextAttribute(hConsoleOutput uintptr, wAttributes uint16) bool { - ret, _, _ := procSetConsoleTextAttribute.Call( - hConsoleOutput, - uintptr(wAttributes)) - return ret != 0 -} - -type coord struct { - X, Y int16 -} - -type small_rect struct { - Left, Top, Right, Bottom int16 -} - -type console_screen_buffer_info struct { - DwSize coord - DwCursorPosition coord - WAttributes uint16 - SrWindow small_rect - DwMaximumWindowSize coord -} - -func getConsoleScreenBufferInfo(hConsoleOutput uintptr) *console_screen_buffer_info { - var csbi console_screen_buffer_info - ret, _, _ := procGetConsoleScreenBufferInfo.Call( - hConsoleOutput, - uintptr(unsafe.Pointer(&csbi))) - if ret == 0 { - return nil - } - return &csbi -} - -const ( - std_output_handle = uint32(-11 & 0xFFFFFFFF) -) - -func init() { - kernel32 := syscall.NewLazyDLL("kernel32.dll") - - procGetStdHandle = kernel32.NewProc("GetStdHandle") - - hStdout, _, _ = procGetStdHandle.Call(uintptr(std_output_handle)) - - initScreenInfo = getConsoleScreenBufferInfo(hStdout) - - syscall.LoadDLL("") -} - -func resetColor() { - if initScreenInfo == nil { // No console info - Ex: stdout redirection - return - } - setConsoleTextAttribute(hStdout, initScreenInfo.WAttributes) -} - -func changeColor(fg Color, fgBright bool, bg Color, bgBright bool) { - attr := uint16(0) - if fg == None || bg == None { - cbufinfo := getConsoleScreenBufferInfo(hStdout) - if cbufinfo == nil { // No console info - Ex: stdout redirection - return - } - attr = getConsoleScreenBufferInfo(hStdout).WAttributes - } // if - - if fg != None { - attr = attr & ^foreground_mask | fg_colors[fg] - if fgBright { - attr |= foreground_intensity - } // if - } // if - - if bg != None { - attr = attr & ^background_mask | bg_colors[bg] - if bgBright { - attr |= background_intensity - } // if - } // if - - setConsoleTextAttribute(hStdout, attr) -} diff --git a/vendor/github.com/subosito/gotenv/.env b/vendor/github.com/subosito/gotenv/.env deleted file mode 100644 index 6405eca..0000000 --- a/vendor/github.com/subosito/gotenv/.env +++ /dev/null @@ -1 +0,0 @@ -HELLO=world diff --git a/vendor/github.com/subosito/gotenv/.gitignore b/vendor/github.com/subosito/gotenv/.gitignore deleted file mode 100644 index 7c7dff2..0000000 --- a/vendor/github.com/subosito/gotenv/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.test -annotate.json diff --git a/vendor/github.com/subosito/gotenv/LICENSE b/vendor/github.com/subosito/gotenv/LICENSE deleted file mode 100644 index f64ccae..0000000 --- a/vendor/github.com/subosito/gotenv/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2013 Alif Rachmawadi - -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/subosito/gotenv/README.md b/vendor/github.com/subosito/gotenv/README.md deleted file mode 100644 index 196683f..0000000 --- a/vendor/github.com/subosito/gotenv/README.md +++ /dev/null @@ -1,102 +0,0 @@ -# gotenv - -Load environment variables dynamically in Go. - -|- | - | -|---------------|----------------------------------------------------| -| Build Status | [![Build Status][drone-img]][drone-url] | -| Coverage | [![Coverage Status][coveralls-img]][coveralls-url] | -| Documentation | http://godoc.org/github.com/subosito/gotenv | - -## Installation - -```bash -$ go get github.com/subosito/gotenv -``` - -## Usage - -Store your configuration to `.env` file on your root directory of your project: - -``` -APP_ID=1234567 -APP_SECRET=abcdef -``` - -Put the gotenv package on your `import` statement: - -```go -import "github.com/subosito/gotenv" -``` - -Then somewhere on your application code, put: - -```go -gotenv.Load() -``` - -Behind the scene it will then load `.env` file and export the valid variables to the environment variables. Make sure you call the method as soon as possible to ensure all variables are loaded, say, put it on `init()` function. - -Once loaded you can use `os.Getenv()` to get the value of the variable. - -Here's the final example: - -```go -package main - -import ( - "github.com/subosito/gotenv" - "log" - "os" -) - -func init() { - gotenv.Load() -} - -func main() { - log.Println(os.Getenv("APP_ID")) // "1234567" - log.Println(os.Getenv("APP_SECRET")) // "abcdef" -} -``` - -You can also load other than `.env` file if you wish. Just supply filenames when calling `Load()`: - -```go -gotenv.Load(".env.production", "credentials") -``` - -That's it :) - -### Another Scenario - -Just in case you want to parse environment variables from any `io.Reader`, gotenv keeps its `Parse()` function as public API so you can utilize that. - -```go -// import "strings" - -pairs := gotenv.Parse(strings.NewReader("FOO=test\nBAR=$FOO")) -// gotenv.Env{"FOO": "test", "BAR": "test"} - -pairs = gotenv.Parse(strings.NewReader(`FOO="bar"`)) -// gotenv.Env{"FOO": "bar"} -``` - -Parse ignores invalid lines and returns `Env` of valid environment variables. - -### Formats - -The gotenv supports various format for defining environment variables. You can see more about it on: - -- [fixtures](./fixtures) -- [gotenv_test.go](./gotenv_test.go) - -## Notes - -The gotenv package is a Go port of [`dotenv`](https://github.com/bkeepers/dotenv) project. Most logic and regexp pattern is taken from there and aims will be compatible as close as possible. - -[drone-img]: https://drone.io/github.com/subosito/gotenv/status.png -[drone-url]: https://drone.io/github.com/subosito/gotenv/latest -[coveralls-img]: https://coveralls.io/repos/subosito/gotenv/badge.png?branch=master -[coveralls-url]: https://coveralls.io/r/subosito/gotenv?branch=master - diff --git a/vendor/github.com/subosito/gotenv/gotenv.go b/vendor/github.com/subosito/gotenv/gotenv.go deleted file mode 100644 index c7a7b09..0000000 --- a/vendor/github.com/subosito/gotenv/gotenv.go +++ /dev/null @@ -1,119 +0,0 @@ -// Package gotenv provides functionality to dynamically load the environment variables -package gotenv - -import ( - "bufio" - "io" - "os" - "regexp" - "strings" -) - -const ( - // Pattern for detecting valid line format - linePattern = `\A(?:export\s+)?([\w\.]+)(?:\s*=\s*|:\s+?)('(?:\'|[^'])*'|"(?:\"|[^"])*"|[^#\n]+)?(?:\s*\#.*)?\z` - - // Pattern for detecting valid variable within a value - variablePattern = `(\\)?(\$)(\{?([A-Z0-9_]+)\}?)` -) - -// Holds key/value pair of valid environment variable -type Env map[string]string - -/* -Load is function to load a file or multiple files and then export the valid variables which found into environment variables. -When it's called with no argument, it will load `.env` file on the current path and set the environment variables. -Otherwise, it will loop over the filenames parameter and set the proper environment variables. - - // processing `.env` - gotenv.Load() - - // processing multiple files - gotenv.Load("production.env", "credentials") - -*/ -func Load(filenames ...string) error { - if len(filenames) == 0 { - filenames = []string{".env"} - } - - for _, filename := range filenames { - f, err := os.Open(filename) - if err != nil { - return err - } - defer f.Close() - - // set environment - env := Parse(f) - for key, val := range env { - os.Setenv(key, val) - } - } - - return nil -} - -// Parse if a function to parse line by line any io.Reader supplied and returns the valid Env key/value pair of valid variables. -// It expands the value of a variable from environment variable, but does not set the value to the environment itself. -// This function is skipping any invalid lines and only processing the valid one. -func Parse(r io.Reader) Env { - env := make(Env) - scanner := bufio.NewScanner(r) - - for scanner.Scan() { - parseLine(scanner.Text(), env) - } - - return env -} - -func parseLine(s string, env Env) { - r := regexp.MustCompile(linePattern) - matches := r.FindStringSubmatch(s) - if len(matches) == 0 { - return - } - - key := matches[1] - val := matches[2] - - // determine if string has quote prefix - hq := strings.HasPrefix(val, `"`) - - // trim whitespace - val = strings.Trim(val, " ") - - // remove quotes '' or "" - rq := regexp.MustCompile(`\A(['"])(.*)(['"])\z`) - val = rq.ReplaceAllString(val, "$2") - - if hq { - val = strings.Replace(val, `\n`, "\n", -1) - // Unescape all characters except $ so variables can be escaped properly - re := regexp.MustCompile(`\\([^$])`) - val = re.ReplaceAllString(val, "$1") - } - - rv := regexp.MustCompile(variablePattern) - xv := rv.FindStringSubmatch(val) - - if len(xv) > 0 { - var replace string - var ok bool - - if xv[1] == "\\" { - replace = strings.Join(xv[2:4], "") - } else { - replace, ok = env[xv[4]] - if !ok { - replace = os.Getenv(xv[4]) - } - } - - val = strings.Replace(val, strings.Join(xv[0:1], ""), replace, -1) - } - - env[key] = val - return -} From f04529d350fb2bf8efbb3e7aa8cd2c1958271d8b Mon Sep 17 00:00:00 2001 From: Jaime Pillora Date: Wed, 29 Dec 2021 23:22:23 +0000 Subject: [PATCH 2/5] drop 32bit --- .github/goreleaser.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/goreleaser.yml b/.github/goreleaser.yml index 82d9f61..4c0cc35 100644 --- a/.github/goreleaser.yml +++ b/.github/goreleaser.yml @@ -11,7 +11,6 @@ builds: - darwin - windows goarch: - - 386 - amd64 - arm - arm64 From 69caece17bdd7f7c908a1e6c92fc9c152ab5795a Mon Sep 17 00:00:00 2001 From: Jaime Pillora Date: Thu, 30 Dec 2021 04:38:45 +0000 Subject: [PATCH 3/5] fixed --- .github/goreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/goreleaser.yml b/.github/goreleaser.yml index 4c0cc35..4cea8e6 100644 --- a/.github/goreleaser.yml +++ b/.github/goreleaser.yml @@ -1,5 +1,5 @@ # test this file with -# goreleaser --skip-publish --rm-dist --config goreleaser.yml +# goreleaser --skip-publish --rm-dist --config .github/goreleaser.yml builds: - main: ./main.go env: From b7dd05e7d84ba44470b2fc2a05b81551d01db0e5 Mon Sep 17 00:00:00 2001 From: Jaime Pillora Date: Thu, 30 Dec 2021 04:40:17 +0000 Subject: [PATCH 4/5] revert --- .github/goreleaser.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/goreleaser.yml b/.github/goreleaser.yml index 4cea8e6..d4157b8 100644 --- a/.github/goreleaser.yml +++ b/.github/goreleaser.yml @@ -1,7 +1,7 @@ # test this file with # goreleaser --skip-publish --rm-dist --config .github/goreleaser.yml builds: - - main: ./main.go + - main: . env: - CGO_ENABLED=0 ldflags: @@ -14,6 +14,7 @@ builds: - amd64 - arm - arm64 + - 386 goarm: - 6 - 7 From 0a6ce1e70ff46333988ad6520f2681e9e626631a Mon Sep 17 00:00:00 2001 From: Jaime Pillora Date: Tue, 16 Aug 2022 08:25:02 +1000 Subject: [PATCH 5/5] Update ci.yml --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb0f9ab..883c57a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,25 +1,31 @@ -on: [push, pull_request] name: CI +on: + pull_request: {} + push: {} + workflow_dispatch: + inputs: {} jobs: # ================ # TEST JOB - # runs on every push and PR - # runs 2x3 times (see matrix) # ================ test: name: Test strategy: matrix: - go-version: [1.16.x, 1.17.x] + go-version: [1.18.x, 1.19.x] platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: - - name: Install Go - uses: actions/setup-go@v1 + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v3 with: go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v2 + check-latest: true + cache: true - name: Build run: go build -v . - name: Test @@ -35,12 +41,21 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: - - name: Check out code - uses: actions/checkout@v2 - - name: goreleaser - if: success() - uses: docker://goreleaser/goreleaser:latest + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.19' + check-latest: true + cache: true + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v3 + with: + distribution: goreleaser + version: latest + args: release --rm-dist --config .github/goreleaser.yml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - args: release --config .github/goreleaser.yml