Pull request 2147: all: upd deps, go, scripts

Squashed commit of the following:

commit 425f1bd28074d22890629d06f43257e0353ce3d5
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Feb 8 20:15:58 2024 +0300

    all: upd deps, go, scripts
This commit is contained in:
Ainar Garipov
2024-02-08 20:39:18 +03:00
parent 02ea4a362c
commit 332621f268
62 changed files with 249 additions and 174 deletions

View File

@@ -30,33 +30,6 @@ set -f -u
# Warnings
go_version="$( "${GO:-go}" version )"
readonly go_version
go_min_version='go1.20.12'
go_version_msg="
warning: your go version (${go_version}) is different from the recommended minimal one (${go_min_version}).
if you have the version installed, please set the GO environment variable.
for example:
export GO='${go_min_version}'
"
readonly go_min_version go_version_msg
case "$go_version"
in
('go version'*"$go_min_version"*)
# Go on.
;;
(*)
echo "$go_version_msg" 1>&2
;;
esac
# Simple analyzers
# blocklist_imports is a simple check against unwanted packages. The following
@@ -74,18 +47,22 @@ esac
#
# See https://github.com/golang/go/issues/45200.
#
# * Package sort is replaced by golang.org/x/exp/slices.
# * Package sort is replaced by package slices.
#
# * Package unsafe is… unsafe.
#
# * Package golang.org/x/exp/slices has been moved into stdlib.
#
# * Package golang.org/x/net/context has been moved into stdlib.
#
# Currently, the only standard exception are files generated from protobuf
# schemas, which use package reflect. If your project needs more exceptions,
# add and document them.
#
# TODO(a.garipov): Add deprecated packages golang.org/x/exp/maps and
# golang.org/x/exp/slices once all projects switch to Go 1.21.
# TODO(a.garipov): Add goilbs/log.
#
# TODO(a.garipov): Add deprecated package golang.org/x/exp/maps once all
# projects switch to Go 1.22.
blocklist_imports() {
git grep\
-e '[[:space:]]"errors"$'\
@@ -94,6 +71,7 @@ blocklist_imports() {
-e '[[:space:]]"reflect"$'\
-e '[[:space:]]"sort"$'\
-e '[[:space:]]"unsafe"$'\
-e '[[:space:]]"golang.org/x/exp/slices"$'\
-e '[[:space:]]"golang.org/x/net/context"$'\
-n\
-- '*.go'\
@@ -124,12 +102,10 @@ underscores() {
underscore_files="$(
git ls-files '*_*.go'\
| grep -F\
-e '_big.go'\
-e '_bsd.go'\
-e '_darwin.go'\
-e '_freebsd.go'\
-e '_linux.go'\
-e '_little.go'\
-e '_next.go'\
-e '_openbsd.go'\
-e '_others.go'\

View File

@@ -51,9 +51,9 @@ readonly count_flags cover_flags shuffle_flags timeout_flags
"$go" test\
"$count_flags"\
"$cover_flags"\
"$shuffle_flags"\
"$race_flags"\
"$shuffle_flags"\
"$timeout_flags"\
"$x_flags"\
"$v_flags"\
"$x_flags"\
./...

View File

@@ -30,8 +30,6 @@ set -e -f -u
go="${GO:-go}"
readonly go
# TODO(a.garipov): Add goconst?
# Remove only the actual binaries in the bin/ directory, as developers may add
# their own scripts there. Most commonly, a script named “go” for tools that
# call the go binary and need a particular version.

View File

@@ -0,0 +1,33 @@
#!/bin/sh
# This comment is used to simplify checking local copies of the script. Bump
# this number every time a significant change is made to this script.
#
# AdGuard-Project-Version: 1
verbose="${VERBOSE:-0}"
readonly verbose
if [ "$verbose" -gt '1' ]
then
env
set -x
x_flags='-x=1'
elif [ "$verbose" -gt '0' ]
then
set -x
x_flags='-x=0'
else
set +x
x_flags='-x=0'
fi
readonly x_flags
set -e -f -u
go="${GO:-go}"
readonly go
cd ./internal/tools/
"$go" get -u
"$go" mod tidy