Skip to content
Open
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
11 changes: 9 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set -e
mydir=$(dirname $0)
GIT_COMMIT=$(git rev-parse HEAD)
RELEASE_VERSION=
extra_opt=
TOPDIR=/tmp/freno-release
export RELEASE_VERSION TOPDIR

Expand Down Expand Up @@ -72,11 +73,17 @@ function precheck() {
ok=1
fi

if ! go version | egrep -q 'go(1\.1[6789])' ; then
GO_VERSION=$(go version | grep -Po "go1\\.\K[0-9]+")
if [[ -z "$GO_VERSION" || "$GO_VERSION" -lt "16" ]]; then
echo "go version must be 1.16 or above"
ok=1
fi

if [[ "$GO_VERSION" -eq "16" ]]; then
# This option is needed only for go 1.16
Comment on lines +82 to +83
Copy link

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

String comparison should be used instead of numeric comparison. Go version numbers like '20' and '21' are valid but this logic incorrectly assumes only Go 1.16 needs the -i flag. Based on Go release notes, the -i flag was deprecated and removed in Go 1.17+, so this condition should check for versions less than 17.

Suggested change
if [[ "$GO_VERSION" -eq "16" ]]; then
# This option is needed only for go 1.16
if [[ "$GO_VERSION" -lt "17" ]]; then
# This option is needed only for go versions less than 1.17

Copilot uses AI. Check for mistakes.

extra_opt="-i"
fi

return $ok
}

Expand Down Expand Up @@ -143,7 +150,7 @@ function build() {
prefix="$4"
ldflags="-X main.AppVersion=${RELEASE_VERSION} -X main.GitCommit=${GIT_COMMIT}"
echo "Building via $(go version)"
gobuild="go build -i ${opt_race} -ldflags \"$ldflags\" -o $builddir/freno${prefix}/freno cmd/freno/main.go"
gobuild="go build ${extra_opt} ${opt_race} -ldflags \"$ldflags\" -o $builddir/freno${prefix}/freno cmd/freno/main.go"

case $os in
'linux')
Expand Down