From 9daa054a322adece0f62594182d306f3d52ec5c9 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 12 Jul 2021 18:05:36 -0400 Subject: [PATCH 1/2] run go generate on CI --- .github/workflows/go-generate.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/go-generate.yml diff --git a/.github/workflows/go-generate.yml b/.github/workflows/go-generate.yml new file mode 100644 index 0000000..2607826 --- /dev/null +++ b/.github/workflows/go-generate.yml @@ -0,0 +1,21 @@ +on: [push, pull_request] +name: go generate + +jobs: + gogenerate: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: "1.16.x" + - name: Go information + run: | + go version + go env + - name: Run go generate + run: | + go generate ./... + git diff --exit-code From c274c8dacbbe402ac09786670a593d511e0f9620 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 15 Jul 2021 21:38:24 +0200 Subject: [PATCH 2/2] add multiformats/multicodec as a git submodule --- .github/workflows/go-generate.yml | 2 ++ .gitmodules | 3 +++ gen.go | 7 +++---- multicodec | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .gitmodules create mode 160000 multicodec diff --git a/.github/workflows/go-generate.yml b/.github/workflows/go-generate.yml index 2607826..349bf01 100644 --- a/.github/workflows/go-generate.yml +++ b/.github/workflows/go-generate.yml @@ -8,6 +8,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + submodules: recursive - uses: actions/setup-go@v2 with: go-version: "1.16.x" diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d94c248 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "multicodec"] + path = multicodec + url = https://github.com/multiformats/multicodec diff --git a/gen.go b/gen.go index 4b0cc78..25cfd6d 100644 --- a/gen.go +++ b/gen.go @@ -7,7 +7,6 @@ import ( "encoding/csv" "io" "log" - "net/http" "os" "strings" "text/template" @@ -69,14 +68,14 @@ func (c tableEntry) VarName() string { } func main() { - resp, err := http.Get("https://raw.githubusercontent.com/multiformats/multicodec/HEAD/table.csv") + f, err := os.Open("multicodec/table.csv") if err != nil { log.Fatal(err) } - defer resp.Body.Close() + defer f.Close() var entries []tableEntry - csvReader := csv.NewReader(resp.Body) + csvReader := csv.NewReader(f) csvReader.Read() // skip the header line for { record, err := csvReader.Read() diff --git a/multicodec b/multicodec new file mode 160000 index 0000000..b1bf92f --- /dev/null +++ b/multicodec @@ -0,0 +1 @@ +Subproject commit b1bf92f815c8a9b2a57c667ac5a1104683cc48a6