Address CGO & sqlite3 building issues
- Migrate from mattn/go-sqlite3 to modernc.org/sqlite - Update .gitignore and .goreleaser.yaml for new build configurations - Add and update dependencies in go.mod and go.sum
- commit
- a4bde1eb7e53fdf7789ad04e52a6d2c62a14e7e4
- author
- bnema · · 2023-10-30 16:08 UTC
- parent
- 04e39ce
- signature
- unsigned
7 files · +99 -27
M .gitignore +2 -0
| @@ -8,4 +8,6 @@ bun.lockb | |||
| 8 | 8 | *.txt | |
| 9 | 9 | *sync-conflict* | |
| 10 | 10 | main | |
| 11 | + | gordon | |
| 11 | 12 | dist/ | |
| 13 | + | data/⏎̸ | |
| @@ -8,4 +8,6 @@ bun.lockb | |||||
| 8 | *.txt | 8 | *.txt | ||
| 9 | *sync-conflict* | 9 | *sync-conflict* | ||
| 10 | main | 10 | main | ||
| 11 | + | gordon | |||
| 11 | dist/ | 12 | dist/ | ||
| 13 | + | data/⏎̸ | |||
M .goreleaser.yaml +14 -17
| @@ -1,34 +1,31 @@ | |||
| 1 | 1 | before: | |
| 2 | 2 | hooks: | |
| 3 | - | # You may remove this if you don't use go modules. | |
| 4 | 3 | - go mod tidy | |
| 5 | 4 | ||
| 6 | 5 | builds: | |
| 7 | 6 | - id: "gordon" | |
| 8 | 7 | main: ./cmd/cli/main.go | |
| 9 | - | ldflags: | |
| 10 | - | - -s -w -X main.build={{.Version}} | |
| 11 | 8 | goos: | |
| 12 | 9 | - linux | |
| 13 | - | - windows | |
| 14 | - | - darwin | |
| 10 | + | goarch: | |
| 11 | + | - amd64 | |
| 12 | + | - arm64 | |
| 13 | + | env: | |
| 14 | + | - CGO_ENABLED=0 | |
| 15 | + | ||
| 16 | + | dockers: | |
| 17 | + | - image_templates: | |
| 18 | + | - bnema/gordon | |
| 19 | + | use: buildx | |
| 20 | + | skip_push: true | |
| 21 | + | dockerfile: Dockerfile | |
| 15 | 22 | ||
| 16 | 23 | archives: | |
| 17 | 24 | - format: tar.gz | |
| 18 | 25 | # this name template makes the OS and Arch compatible with the results of `uname`. | |
| 19 | - | name_template: >- | |
| 20 | - | {{ .ProjectName }}_ | |
| 21 | - | {{- title .Os }}_ | |
| 22 | - | {{- if eq .Arch "amd64" }}x86_64 | |
| 23 | - | {{- else if eq .Arch "386" }}i386 | |
| 24 | - | {{- else }}{{ .Arch }}{{ end }} | |
| 25 | - | {{- if .Arm }}v{{ .Arm }}{{ end }} | |
| 26 | - | # use zip for windows archives | |
| 27 | - | format_overrides: | |
| 28 | - | - goos: windows | |
| 29 | - | format: zip | |
| 26 | + | name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" | |
| 30 | 27 | ||
| 31 | - | changelog: | |
| 28 | + | changelog: # Added this section | |
| 32 | 29 | sort: asc | |
| 33 | 30 | filters: | |
| 34 | 31 | exclude: | |
| @@ -1,34 +1,31 @@ | |||||
| 1 | before: | 1 | before: | ||
| 2 | hooks: | 2 | hooks: | ||
| 3 | - | # You may remove this if you don't use go modules. | |||
| 4 | - go mod tidy | 3 | - go mod tidy | ||
| 5 | 4 | ||||
| 6 | builds: | 5 | builds: | ||
| 7 | - id: "gordon" | 6 | - id: "gordon" | ||
| 8 | main: ./cmd/cli/main.go | 7 | main: ./cmd/cli/main.go | ||
| 9 | - | ldflags: | |||
| 10 | - | - -s -w -X main.build={{.Version}} | |||
| 11 | goos: | 8 | goos: | ||
| 12 | - linux | 9 | - linux | ||
| 13 | - | - windows | 10 | + | goarch: |
| 14 | - | - darwin | 11 | + | - amd64 |
| 12 | + | - arm64 | |||
| 13 | + | env: | |||
| 14 | + | - CGO_ENABLED=0 | |||
| 15 | + | ||||
| 16 | + | dockers: | |||
| 17 | + | - image_templates: | |||
| 18 | + | - bnema/gordon | |||
| 19 | + | use: buildx | |||
| 20 | + | skip_push: true | |||
| 21 | + | dockerfile: Dockerfile | |||
| 15 | 22 | ||||
| 16 | archives: | 23 | archives: | ||
| 17 | - format: tar.gz | 24 | - format: tar.gz | ||
| 18 | # this name template makes the OS and Arch compatible with the results of `uname`. | 25 | # this name template makes the OS and Arch compatible with the results of `uname`. | ||
| 19 | - | name_template: >- | 26 | + | name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" |
| 20 | - | {{ .ProjectName }}_ | |||
| 21 | - | {{- title .Os }}_ | |||
| 22 | - | {{- if eq .Arch "amd64" }}x86_64 | |||
| 23 | - | {{- else if eq .Arch "386" }}i386 | |||
| 24 | - | {{- else }}{{ .Arch }}{{ end }} | |||
| 25 | - | {{- if .Arm }}v{{ .Arm }}{{ end }} | |||
| 26 | - | # use zip for windows archives | |||
| 27 | - | format_overrides: | |||
| 28 | - | - goos: windows | |||
| 29 | - | format: zip | |||
| 30 | 27 | ||||
| 31 | - | changelog: | 28 | + | changelog: # Added this section |
| 32 | sort: asc | 29 | sort: asc | ||
| 33 | filters: | 30 | filters: | ||
| 34 | exclude: | 31 | exclude: | ||
A Dockerfile +7 -0
| @@ -0,0 +1,7 @@ | |||
| 1 | + | FROM scratch | |
| 2 | + | ||
| 3 | + | COPY gordon / | |
| 4 | + | ||
| 5 | + | EXPOSE 1323 | |
| 6 | + | ENTRYPOINT ["/gordon"] | |
| 7 | + | CMD ["serve"] | |
| @@ -0,0 +1,7 @@ | |||||
| 1 | + | FROM scratch | |||
| 2 | + | ||||
| 3 | + | COPY gordon / | |||
| 4 | + | ||||
| 5 | + | EXPOSE 1323 | |||
| 6 | + | ENTRYPOINT ["/gordon"] | |||
| 7 | + | CMD ["serve"] | |||
A docker-compose.yml +15 -0
| @@ -0,0 +1,15 @@ | |||
| 1 | + | version: '3' | |
| 2 | + | ||
| 3 | + | services: | |
| 4 | + | gordon: | |
| 5 | + | image: bnema/gordon:latest | |
| 6 | + | ports: | |
| 7 | + | - "1323" | |
| 8 | + | environment: | |
| 9 | + | SESSION_SECRET: "secret" | |
| 10 | + | DEV: false | |
| 11 | + | volumes: | |
| 12 | + | - ./data:/data | |
| 13 | + | - .config.yml:/config.yml | |
| 14 | + | - /var/run/docker.sock:/var/run/docker.sock | |
| 15 | + | ||
| @@ -0,0 +1,15 @@ | |||||
| 1 | + | version: '3' | |||
| 2 | + | ||||
| 3 | + | services: | |||
| 4 | + | gordon: | |||
| 5 | + | image: bnema/gordon:latest | |||
| 6 | + | ports: | |||
| 7 | + | - "1323" | |||
| 8 | + | environment: | |||
| 9 | + | SESSION_SECRET: "secret" | |||
| 10 | + | DEV: false | |||
| 11 | + | volumes: | |||
| 12 | + | - ./data:/data | |||
| 13 | + | - .config.yml:/config.yml | |||
| 14 | + | - /var/run/docker.sock:/var/run/docker.sock | |||
| 15 | + | ||||
M go.mod +16 -3
| @@ -10,17 +10,30 @@ require ( | |||
| 10 | 10 | github.com/joho/godotenv v1.5.1 | |
| 11 | 11 | github.com/labstack/echo-contrib v0.15.0 | |
| 12 | 12 | github.com/labstack/echo/v4 v4.11.1 | |
| 13 | - | github.com/mattn/go-sqlite3 v1.14.17 | |
| 14 | 13 | github.com/microcosm-cc/bluemonday v1.0.25 | |
| 15 | 14 | github.com/spf13/cobra v1.7.0 | |
| 16 | 15 | gopkg.in/yaml.v3 v3.0.1 | |
| 16 | + | modernc.org/sqlite v1.26.0 | |
| 17 | 17 | ) | |
| 18 | 18 | ||
| 19 | 19 | require ( | |
| 20 | + | github.com/dustin/go-humanize v1.0.1 // indirect | |
| 20 | 21 | github.com/inconshreveable/mousetrap v1.1.0 // indirect | |
| 22 | + | github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect | |
| 21 | 23 | github.com/kr/text v0.2.0 // indirect | |
| 24 | + | github.com/mattn/go-sqlite3 v1.14.17 // indirect | |
| 25 | + | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect | |
| 22 | 26 | github.com/spf13/pflag v1.0.5 // indirect | |
| 23 | 27 | github.com/stretchr/testify v1.8.2 // indirect | |
| 28 | + | lukechampine.com/uint128 v1.3.0 // indirect | |
| 29 | + | modernc.org/cc/v3 v3.41.0 // indirect | |
| 30 | + | modernc.org/ccgo/v3 v3.16.15 // indirect | |
| 31 | + | modernc.org/libc v1.29.0 // indirect | |
| 32 | + | modernc.org/mathutil v1.6.0 // indirect | |
| 33 | + | modernc.org/memory v1.7.2 // indirect | |
| 34 | + | modernc.org/opt v0.1.3 // indirect | |
| 35 | + | modernc.org/strutil v1.2.0 // indirect | |
| 36 | + | modernc.org/token v1.1.0 // indirect | |
| 24 | 37 | ) | |
| 25 | 38 | ||
| 26 | 39 | require ( | |
| @@ -31,13 +44,13 @@ require ( | |||
| 31 | 44 | github.com/docker/go-units v0.5.0 // indirect | |
| 32 | 45 | github.com/gogo/protobuf v1.3.2 // indirect | |
| 33 | 46 | github.com/golang-jwt/jwt v3.2.2+incompatible // indirect | |
| 34 | - | github.com/google/uuid v1.3.1 // direct | |
| 47 | + | github.com/google/uuid v1.4.0 // direct | |
| 35 | 48 | github.com/gorilla/context v1.1.1 // indirect | |
| 36 | 49 | github.com/gorilla/css v1.0.0 // indirect | |
| 37 | 50 | github.com/gorilla/securecookie v1.1.1 // indirect | |
| 38 | 51 | github.com/labstack/gommon v0.4.0 // indirect | |
| 39 | 52 | github.com/mattn/go-colorable v0.1.13 // indirect | |
| 40 | - | github.com/mattn/go-isatty v0.0.19 // indirect | |
| 53 | + | github.com/mattn/go-isatty v0.0.20 // indirect | |
| 41 | 54 | github.com/moby/term v0.5.0 // indirect | |
| 42 | 55 | github.com/morikuni/aec v1.0.0 // indirect | |
| 43 | 56 | github.com/opencontainers/go-digest v1.0.0 // indirect | |
| @@ -10,17 +10,30 @@ require ( | |||||
| 10 | github.com/joho/godotenv v1.5.1 | 10 | github.com/joho/godotenv v1.5.1 | ||
| 11 | github.com/labstack/echo-contrib v0.15.0 | 11 | github.com/labstack/echo-contrib v0.15.0 | ||
| 12 | github.com/labstack/echo/v4 v4.11.1 | 12 | github.com/labstack/echo/v4 v4.11.1 | ||
| 13 | - | github.com/mattn/go-sqlite3 v1.14.17 | |||
| 14 | github.com/microcosm-cc/bluemonday v1.0.25 | 13 | github.com/microcosm-cc/bluemonday v1.0.25 | ||
| 15 | github.com/spf13/cobra v1.7.0 | 14 | github.com/spf13/cobra v1.7.0 | ||
| 16 | gopkg.in/yaml.v3 v3.0.1 | 15 | gopkg.in/yaml.v3 v3.0.1 | ||
| 16 | + | modernc.org/sqlite v1.26.0 | |||
| 17 | ) | 17 | ) | ||
| 18 | 18 | ||||
| 19 | require ( | 19 | require ( | ||
| 20 | + | github.com/dustin/go-humanize v1.0.1 // indirect | |||
| 20 | github.com/inconshreveable/mousetrap v1.1.0 // indirect | 21 | github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
| 22 | + | github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect | |||
| 21 | github.com/kr/text v0.2.0 // indirect | 23 | github.com/kr/text v0.2.0 // indirect | ||
| 24 | + | github.com/mattn/go-sqlite3 v1.14.17 // indirect | |||
| 25 | + | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect | |||
| 22 | github.com/spf13/pflag v1.0.5 // indirect | 26 | github.com/spf13/pflag v1.0.5 // indirect | ||
| 23 | github.com/stretchr/testify v1.8.2 // indirect | 27 | github.com/stretchr/testify v1.8.2 // indirect | ||
| 28 | + | lukechampine.com/uint128 v1.3.0 // indirect | |||
| 29 | + | modernc.org/cc/v3 v3.41.0 // indirect | |||
| 30 | + | modernc.org/ccgo/v3 v3.16.15 // indirect | |||
| 31 | + | modernc.org/libc v1.29.0 // indirect | |||
| 32 | + | modernc.org/mathutil v1.6.0 // indirect | |||
| 33 | + | modernc.org/memory v1.7.2 // indirect | |||
| 34 | + | modernc.org/opt v0.1.3 // indirect | |||
| 35 | + | modernc.org/strutil v1.2.0 // indirect | |||
| 36 | + | modernc.org/token v1.1.0 // indirect | |||
| 24 | ) | 37 | ) | ||
| 25 | 38 | ||||
| 26 | require ( | 39 | require ( | ||
| @@ -31,13 +44,13 @@ require ( | |||||
| 31 | github.com/docker/go-units v0.5.0 // indirect | 44 | github.com/docker/go-units v0.5.0 // indirect | ||
| 32 | github.com/gogo/protobuf v1.3.2 // indirect | 45 | github.com/gogo/protobuf v1.3.2 // indirect | ||
| 33 | github.com/golang-jwt/jwt v3.2.2+incompatible // indirect | 46 | github.com/golang-jwt/jwt v3.2.2+incompatible // indirect | ||
| 34 | - | github.com/google/uuid v1.3.1 // direct | 47 | + | github.com/google/uuid v1.4.0 // direct |
| 35 | github.com/gorilla/context v1.1.1 // indirect | 48 | github.com/gorilla/context v1.1.1 // indirect | ||
| 36 | github.com/gorilla/css v1.0.0 // indirect | 49 | github.com/gorilla/css v1.0.0 // indirect | ||
| 37 | github.com/gorilla/securecookie v1.1.1 // indirect | 50 | github.com/gorilla/securecookie v1.1.1 // indirect | ||
| 38 | github.com/labstack/gommon v0.4.0 // indirect | 51 | github.com/labstack/gommon v0.4.0 // indirect | ||
| 39 | github.com/mattn/go-colorable v0.1.13 // indirect | 52 | github.com/mattn/go-colorable v0.1.13 // indirect | ||
| 40 | - | github.com/mattn/go-isatty v0.0.19 // indirect | 53 | + | github.com/mattn/go-isatty v0.0.20 // indirect |
| 41 | github.com/moby/term v0.5.0 // indirect | 54 | github.com/moby/term v0.5.0 // indirect | ||
| 42 | github.com/morikuni/aec v1.0.0 // indirect | 55 | github.com/morikuni/aec v1.0.0 // indirect | ||
| 43 | github.com/opencontainers/go-digest v1.0.0 // indirect | 56 | github.com/opencontainers/go-digest v1.0.0 // indirect | ||
M go.sum +40 -4 generated file: collapsed
M internal/server/sqliteinit.go +5 -3
| @@ -8,7 +8,7 @@ import ( | |||
| 8 | 8 | ||
| 9 | 9 | "github.com/bnema/gordon/internal/db" | |
| 10 | 10 | pkgsqlite "github.com/bnema/gordon/pkg/sqlite" | |
| 11 | - | _ "github.com/mattn/go-sqlite3" | |
| 11 | + | _ "modernc.org/sqlite" | |
| 12 | 12 | ) | |
| 13 | 13 | ||
| 14 | 14 | const ( | |
| @@ -59,7 +59,8 @@ func InitializeDB(a *App) (*sql.DB, error) { | |||
| 59 | 59 | } | |
| 60 | 60 | } | |
| 61 | 61 | ||
| 62 | - | db, err := sql.Open("sqlite3", dbPath) | |
| 62 | + | // Change here from "sqlite3" to "sqlite" | |
| 63 | + | db, err := sql.Open("sqlite", dbPath) | |
| 63 | 64 | if err != nil { | |
| 64 | 65 | return nil, fmt.Errorf("failed to open disk DB: %w", err) | |
| 65 | 66 | } | |
| @@ -77,7 +78,8 @@ func InitializeDB(a *App) (*sql.DB, error) { | |||
| 77 | 78 | } | |
| 78 | 79 | ||
| 79 | 80 | func bootstrapDB(dbPath string, app *App) error { | |
| 80 | - | db, err := sql.Open("sqlite3", dbPath) | |
| 81 | + | // Change here from "sqlite3" to "sqlite" | |
| 82 | + | db, err := sql.Open("sqlite", dbPath) | |
| 81 | 83 | if err != nil { | |
| 82 | 84 | return err | |
| 83 | 85 | } | |
| @@ -8,7 +8,7 @@ import ( | |||||
| 8 | 8 | ||||
| 9 | "github.com/bnema/gordon/internal/db" | 9 | "github.com/bnema/gordon/internal/db" | ||
| 10 | pkgsqlite "github.com/bnema/gordon/pkg/sqlite" | 10 | pkgsqlite "github.com/bnema/gordon/pkg/sqlite" | ||
| 11 | - | _ "github.com/mattn/go-sqlite3" | 11 | + | _ "modernc.org/sqlite" |
| 12 | ) | 12 | ) | ||
| 13 | 13 | ||||
| 14 | const ( | 14 | const ( | ||
| @@ -59,7 +59,8 @@ func InitializeDB(a *App) (*sql.DB, error) { | |||||
| 59 | } | 59 | } | ||
| 60 | } | 60 | } | ||
| 61 | 61 | ||||
| 62 | - | db, err := sql.Open("sqlite3", dbPath) | 62 | + | // Change here from "sqlite3" to "sqlite" |
| 63 | + | db, err := sql.Open("sqlite", dbPath) | |||
| 63 | if err != nil { | 64 | if err != nil { | ||
| 64 | return nil, fmt.Errorf("failed to open disk DB: %w", err) | 65 | return nil, fmt.Errorf("failed to open disk DB: %w", err) | ||
| 65 | } | 66 | } | ||
| @@ -77,7 +78,8 @@ func InitializeDB(a *App) (*sql.DB, error) { | |||||
| 77 | } | 78 | } | ||
| 78 | 79 | ||||
| 79 | func bootstrapDB(dbPath string, app *App) error { | 80 | func bootstrapDB(dbPath string, app *App) error { | ||
| 80 | - | db, err := sql.Open("sqlite3", dbPath) | 81 | + | // Change here from "sqlite3" to "sqlite" |
| 82 | + | db, err := sql.Open("sqlite", dbPath) | |||
| 81 | if err != nil { | 83 | if err != nil { | ||
| 82 | return err | 84 | return err | ||
| 83 | } | 85 | } | ||