Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update go to 1.22 #2760

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
# https://docs.github.com/en/packages/guides/pushing-and-pulling-docker-images
#
# Keep this in sync with default in scripts/github-ci.sh.
CI_IMAGE: ghcr.io/bitboxswiss/bitbox-wallet-app-ci:23
CI_IMAGE: ghcr.io/bitboxswiss/bitbox-wallet-app-ci:24
GITHUB_BUILD_DIR: ${{github.workspace}}

jobs:
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.21.x
go-version: 1.22.x
- name: Install Node.js
uses: actions/setup-node@v4
with:
Expand Down
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# options for analysis running
run:
go: "1.21"
go: "1.22"

# default concurrency is a available CPU number
concurrency: 4
Expand Down Expand Up @@ -86,6 +86,8 @@ linters:
- wsl
- execinquery
- ireturn
- copyloopvar
- intrange
- wrapcheck
- varnamelen
- tagliatelle
Expand Down
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ envinit:
go install github.com/vektra/mockery/v2@latest
go install github.com/matryer/moq@latest
go install golang.org/x/tools/cmd/goimports@latest
go install golang.org/x/mobile/cmd/gomobile@latest
# The gomobile/gobind libs are also needed when using `gomobile bind`, but it's not compatible with vendoring:
# https://github.com/golang/go/issues/50994#issuecomment-1032754206
GO111MODULE=off go get -u golang.org/x/mobile/cmd/gomobile
# TODO: replace with go install golang.org/x/mobile/cmd/gomobile@latest once https://github.com/golang/mobile/pull/105 is merged.
git clone https://github.com/BitBoxSwiss/mobile.git && cd /tmp/mobile/cmd/gomobile && go install .
gomobile init
# Initializiation on MacOS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we have a problem.

Above on line 31 there is:

# The gomobile/gobind libs are also needed when using `gomobile bind`, but it's not compatible with vendoring:
	# https://github.com/golang/go/issues/50994#issuecomment-1032754206
	GO111MODULE=off go get -u golang.org/x/mobile/cmd/gomobile

This fails in Go 1.22 because go get is now disabled outside of modules. I locally built an image simply removing this line, but then cd backend/mobileserver; make fails with

unable to import bind: no Go package in golang.org/x/mobile/bind
"golang.org/x/mobile/bind" is not found; run go get golang.org/x/mobile/bind: no Go package in golang.org/x/mobile/bind

Running go get golang.org/x/mobile/bind did not actually fix it for me.

Any idea how to resolve this?

Copy link
Contributor

@benma benma Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried adding a dummy import _ "golang.org/x/mobile/bind" to force it to be vendored, but go mod vendor only vendors files in Go folders, but bind has files like these that are then missing:

gomobile: /opt/go/bin/gobind -lang=go,java -outdir=/tmp/gomobile-work-2993124781 github.com/BitBoxSwiss/bitbox-wallet-app/backend/mobileserver failed: exit status 1
failed to open Java support file: open /opt/go/src/github.com/BitBoxSwiss/bitbox-wallet-app/vendor/golang.org/x/mobile/bind/java/Seq.java: no such file or directory

EDIT: according to golang/go#43736 (comment) this should have been fixed 🤔

EDIT2: With the _ "golang.org/x/mobile/cmd/gobind" import path the Java files are vendored, but the generated code is not modules aware it seems:

PWD=$WORK/src-android-386 GOMODCACHE=$GOPATH/pkg/mod GOOS=android GOARCH=386 CC=$ANDROID_HOME/ndk/21.2.6472646/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android16-clang CXX=$ANDROID_HOME/ndk/21.2.6472646/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android16-clang++ CGO_ENABLED=1 GOPATH=$WORK:$GOPATH go mod tidy
rm -r -f "$WORK"
gomobile: go mod tidy failed: exit status 1
go: error reading go.mod: missing module declaration. To specify the module path:
        go mod edit -module=example.com/mod

I filed an issue here: golang/go#67927

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A workaround that seems to work is to mv vendor vendor.disabled before make android and move it back after 🙀

# - run make from $GOPATH/src/github.com/BitBoxSwiss/bitbox-wallet-app
# - additional dependencies: Qt 5.15 & Xcode command line tools
# - add to $PATH: /usr/local/opt/go@1.21/bin
# - add to $PATH: /usr/local/opt/go@1.22/bin
osx-init:
./scripts/osx-brew.sh
$(MAKE) envinit
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The below instructions assume a unix environment.

To build the app or run the development workflow, the following dependencies need to be installed:

- [Go](https://golang.org/doc/install) version 1.21
- [Go](https://golang.org/doc/install) version 1.22
- [Node.js](https://nodejs.org/) version 20.x
- [NPM](https://docs.npmjs.com/about-npm-versions) version 10.x or newer
- [Qt5](https://www.qt.io) version 5.15.2
Expand Down
2 changes: 2 additions & 0 deletions android-env.mk.inc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export ANDROID_SDK_ROOT := /opt/android-sdk
export ANDROID_NDK_HOME := /opt/android-sdk/ndk/21.2.6472646
# gomodcache location for gomobile build pkgs. Set to tmp folder, because writing access is needed.
export GOMODCACHE_ROOT := /tmp/gomodcache/pkg/mod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this? Is it required? If so, please add a comment why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment.

11 changes: 6 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ environment:
nodejs_version: "20"
matrix:
- QT: C:\Qt\5.15.2\msvc2019_64
GOROOT: C:\go121
# As installed by `choco`
GOROOT: C:\Program Files\Go
GOPATH: C:\gopath\
GOTOOLCHAIN: local
PLATFORM: amd64
COMPILER: msvc

# https://www.appveyor.com/docs/windows-images-software/#golang
baizon marked this conversation as resolved.
Show resolved Hide resolved
# If you change this, also change the GOROOT variable above to point to the right installation folder.
stack: go 1.21

install:
- ps: Install-Product node $env:nodejs_version
- git submodule update --init --recursive
Expand All @@ -26,6 +24,9 @@ before_build:

build_script:
- echo on
- choco install go --version=1.22.6
- go version
- go env
- choco install make
- choco install nsis -pre
- mkdir %GOPATH%\src\github.com\BitBoxSwiss
Expand Down
9 changes: 4 additions & 5 deletions backend/mobileserver/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
include ../../android-env.mk.inc

# go mod makes the Android build hang forever. Remove this once we move to go modules in a controlled fashion.
# Probably a variation of https://github.com/golang/go/issues/27234 - solution is to build it using vendored deps
# by turning off GO111MODULE. See also: https://github.com/golang/go/issues/34181#issuecomment-640260162
# GOMODCACHE to /tmp directory, because gomobile needs to write pkgs.
# Also set -glflags to fix the vendor issue with gomobile, see: https://github.com/golang/go/issues/67927#issuecomment-2241523694
build-android:
GO111MODULE=off ANDROID_HOME=${ANDROID_SDK_ROOT} gomobile bind -x -a -ldflags="-s -w" -target android .
GOMODCACHE=${GOMODCACHE_ROOT} ANDROID_HOME=${ANDROID_SDK_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target android .
build-ios:
GO111MODULE=off gomobile bind -x -a -ldflags="-s -w" -target ios,iossimulator .
GOMODCACHE=${GOMODCACHE_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target ios,iossimulator .
clean:
rm -f mobileserver.aar mobileserver-sources.jar
9 changes: 9 additions & 0 deletions backend/mobileserver/implicit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file imports the packages required by gomobile so they can be vendored.

package mobileserver

import (
_ "golang.org/x/mobile/bind"
_ "golang.org/x/mobile/bind/java"
_ "golang.org/x/mobile/bind/objc"
)
6 changes: 3 additions & 3 deletions docs/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ Build artifacts:

## MacOS

Make sure you have `qt@5/bin`, `go@1.21/bin` and `go/bin` in your PATH, i.e. add to your `.zshrc`
Make sure you have `qt@5/bin`, `go@1.22/bin` and `go/bin` in your PATH, i.e. add to your `.zshrc`

```bash
export PATH="$PATH:/usr/local/opt/qt@5/bin"
export PATH="$PATH:/usr/local/opt/go@1.21/bin"
export PATH="$PATH:/usr/local/opt/go@1.22/bin"
export PATH="$PATH:$HOME/go/bin"
```

Expand Down Expand Up @@ -73,7 +73,7 @@ xcrun altool --list-providers --username "APPLE_ID" --password "PASSWORD"
The build requires `Microsoft Visual Studio 2019 Community Edition`, with the `MSVC v142 - VS 2019 C++ x64/x86 build tools (Latest)`
individual component.

It also requires `mingw-w64`, `bash` (e.g. `git-bash`), `make`,`go 1.21`, `node@20`, `QT 5.15.2` with `qtwebengine`, `nsis`
It also requires `mingw-w64`, `bash` (e.g. `git-bash`), `make`,`go 1.22`, `node@20`, `QT 5.15.2` with `qtwebengine`, `nsis`
and possibly other tools.

Some of the tools are easy to install with `choco`:
Expand Down
3 changes: 2 additions & 1 deletion frontends/qt/server/Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ CGO=1
BUILDMODE=c-shared
GOARCH=amd64
GOOS=linux
GOTOOLCHAIN=local

linux:
CC=clang \
CGO_CFLAGS="${GOLNXSECFLAGS} ${CFLAGS}" \
CGO_LDFLAGS="${GOLNXLDFLAGS} ${LFLAGS}" \
GOARCH=${GOARCH} CGO_ENABLED=${CGO} GOOS=${GOOS} \
GOARCH=${GOARCH} CGO_ENABLED=${CGO} GOOS=${GOOS} GOTOOLCHAIN=${GOTOOLCHAIN} \
go build -x -mod=vendor -buildmode=${BUILDMODE} -ldflags \
-extldflags="${GOLNXEXTLDFLAGS}" -o ${LIBNAME}.so

Expand Down
3 changes: 2 additions & 1 deletion frontends/qt/server/Makefile.macosx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ CGO=1
BUILDMODE=c-shared
GOARCH=amd64
GOOS=darwin
GOTOOLCHAIN=local

darwin:
CGO_CFLAGS="-g ${GODARWINSECFLAGS} ${CFLAGS}" \
CGO_LDFLAGS="${GODARWINLDFLAGS} ${LFLAGS}" \
MACOSX_DEPLOYMENT_TARGET=${MACOS_MIN_VERSION} \
GOARCH=${GOARCH} CGO_ENABLED=${CGO} GOOS=${GOOS} \
GOARCH=${GOARCH} CGO_ENABLED=${CGO} GOOS=${GOOS} GOTOOLCHAIN=${GOTOOLCHAIN} \
go build -ldflags='-s' -x -mod=vendor \
-buildmode="c-shared" -o ${LIBNAME}.so

Expand Down
5 changes: 3 additions & 2 deletions frontends/qt/server/Makefile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ CGO=1
BUILDMODE=c-shared
GOARCH=amd64
GOOS=windows
GOTOOLCHAIN=local

windows:
CGO_CFLAGS="${GOWINSECFLAGS} ${CFLAGS}" \
CGO_LDFLAGS="${GOWINLDFLAGS} ${LFLAGS}" \
GOARCH=${GOARCH} CGO_ENABLED=${CGO} GOOS=${GOOS} \
GOARCH=${GOARCH} CGO_ENABLED=${CGO} GOOS=${GOOS} GOTOOLCHAIN=${GOTOOLCHAIN} \
go build -x -mod=vendor \
-buildmode="${BUILDMODE}" -o ${LIBNAME}.dll

Expand All @@ -17,7 +18,7 @@ windows-cross:
CC_FOR_TARGET=/usr/bin/x86_64-w64-mingw32-gcc \
CGO_CFLAGS="-g ${GOWINSECFLAGS} ${CFLAGS}" \
CGO_LDFLAGS="${GOWINLDFLAGS} ${LFLAGS}" \
GOARCH=${GOARCH} CGO_ENABLED=${CGO} GOOS=${GOOS} \
GOARCH=${GOARCH} CGO_ENABLED=${CGO} GOOS=${GOOS} GOTOOLCHAIN=${GOTOOLCHAIN} \
go build -x -mod=vendor \
-buildmode="${BUILDMODE}" -o ${LIBNAME}.dll

Expand Down
7 changes: 4 additions & 3 deletions frontends/web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/BitBoxSwiss/bitbox-wallet-app

go 1.21
go 1.22

require (
github.com/BitBoxSwiss/bitbox02-api-go v0.0.0-20240726181108-383ad4bcada4
Expand All @@ -20,6 +20,7 @@ require (
github.com/stretchr/testify v1.9.0
go.etcd.io/bbolt v1.3.10
golang.org/x/crypto v0.26.0
golang.org/x/mobile v0.0.0-20240716161057-1ad2df20a8b6
golang.org/x/net v0.28.0
)

Expand Down Expand Up @@ -54,8 +55,10 @@ require (
github.com/tklauser/numcpus v0.8.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
Expand Down
Loading
Loading