From 15ff3ff6431e1ab7d7d2b5a47e0b813e4db2df88 Mon Sep 17 00:00:00 2001 From: Ed Harrod Date: Wed, 23 Aug 2023 15:04:07 +0100 Subject: [PATCH] Run Gofumpt, add go.work (#3) * gofumpt: Run on repo, tidy * add go.work file * Use latest danger-go version --- .github/workflows/main.yml | 2 +- README.md | 7 +------ danger-js/danger-js.go | 10 ++++++---- go.work | 6 ++++++ go.work.sum | 2 ++ 5 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 go.work create mode 100644 go.work.sum diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d9131f6..26681ab 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: run: npm install -g danger - name: Install danger-go - run: go install github.com/luno/danger-go/cmd/danger-go@v0.2.0 # match version used in build/ci + run: go install github.com/luno/danger-go/cmd/danger-go - name: Check versions run: | diff --git a/README.md b/README.md index c5a798e..9cbcca1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - # Danger in Go This is a Go version of the popular [Danger](https://danger.systems/) tool. @@ -19,11 +18,7 @@ Requires [Danger JS](https://danger.systems/js) to run properly. ```go package main -import ( - "fmt" - - "github.com/luno/danger-go" -) +import "github.com/luno/danger-go" func Run(d *danger.T, pr danger.DSL) { d.Message("danger-go is running!", "", 0) diff --git a/danger-js/danger-js.go b/danger-js/danger-js.go index 3ddbbda..9ede2c7 100644 --- a/danger-js/danger-js.go +++ b/danger-js/danger-js.go @@ -8,8 +8,10 @@ import ( "strings" ) -const dangerJsBinary = "danger" -const dangerGoBinary = "danger-go" +const ( + dangerJsBinary = "danger" + dangerGoBinary = "danger-go" +) func findBinary(name string) (string, error) { cmd := exec.Command("which", name) @@ -36,7 +38,7 @@ func GetPR(url string, dangerBin string) (DSL, error) { } var pr DSL - if err = json.Unmarshal([]byte(prJSON), &pr); err != nil { + if err = json.Unmarshal(prJSON, &pr); err != nil { return DSL{}, err } return pr, nil @@ -52,7 +54,7 @@ func Process(command string, args []string) error { return err } // The `danger` (javascript) command will call the process specified, - // ie. `danger-go`, with the first argument of `runner` followed by the + // i.e. `danger-go`, with the first argument of `runner` followed by the // arguments it received. cmdArgs := append([]string{command, "--process", dangerGoBin, "--passURLForDSL"}, args...) cmd := exec.Command(dangerBin, cmdArgs...) diff --git a/go.work b/go.work new file mode 100644 index 0000000..7d08a01 --- /dev/null +++ b/go.work @@ -0,0 +1,6 @@ +go 1.20 + +use ( + build/ci + . +) \ No newline at end of file diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 0000000..6e91cd0 --- /dev/null +++ b/go.work.sum @@ -0,0 +1,2 @@ +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=