third_party/go: bump grpc-go
We're about to include some new-ish cloud.google.com/go packages, and
these want a fairly new grpc-go.
This version of grpc-go finally deprecates some resolver struct fields,
which means we need to migrate away from them.
The changes also pull in a bunch of golang.org/x/ updates, including one
that breaks our importsort patch in goimports.
Change-Id: I2570af45694a5bf18eb7fabb44120d19c5e487da
Reviewed-on: https://review.monogon.dev/c/monogon/+/1472
Reviewed-by: Leopold Schabel <leo@monogon.tech>
Tested-by: Jenkins CI
diff --git a/third_party/go/patches/goimports-group-merging.patch b/third_party/go/patches/goimports-group-merging.patch
index ed87faf..87a20b3 100644
--- a/third_party/go/patches/goimports-group-merging.patch
+++ b/third_party/go/patches/goimports-group-merging.patch
@@ -1,5 +1,7 @@
Upstream CL: https://go-review.googlesource.com/c/tools/+/321409
+Modified to work against upstream Go.
+
From cdd84f3789f3ebbd1c55dc220bbbe4a77ab4024a Mon Sep 17 00:00:00 2001
From: Moekr <1143757638wlw@gmail.com>
Date: Thu, 20 May 2021 15:41:17 +0800
@@ -8,19 +10,11 @@
Merge two import groups if there is no comments between them.
This can make import blocks look more pretty.
-Fixes golang/go#20818 golang/go#28200
-
-Change-Id: Ic02ca83bd778e6d5b5b3c15292cde4fba6c842a9
---
- internal/imports/fix_test.go | 65 +++++++++++++++++++++++++++++----
- internal/imports/sortimports.go | 23 ++++++++++--
- 2 files changed, 77 insertions(+), 11 deletions(-)
-
-diff --git a/internal/imports/fix_test.go b/internal/imports/fix_test.go
-index 005bf96e..5ff84cdd 100644
---- a/internal/imports/fix_test.go
-+++ b/internal/imports/fix_test.go
-@@ -553,7 +553,6 @@ c = fmt.Printf
+diff -ur org_golang_x_tools.orig/internal/imports/fix_test.go org_golang_x_tools/internal/imports/fix_test.go
+--- org_golang_x_tools.orig/internal/imports/fix_test.go 2023-04-03 15:16:24.808998544 +0200
++++ org_golang_x_tools/internal/imports/fix_test.go 2023-04-03 15:16:56.069290812 +0200
+@@ -552,7 +552,6 @@
import (
"fmt"
@@ -28,7 +22,7 @@
"gu"
"manypackages.com/packagea"
-@@ -644,15 +643,11 @@ var _, _, _, _, _ = fmt.Errorf, io.Copy, strings.Contains, renamed_packagea.A, B
+@@ -643,15 +642,11 @@
import (
"fmt"
@@ -46,12 +40,10 @@
_ "manypackages.com/packagec"
)
-@@ -1151,6 +1146,62 @@ var _, _ = rand.Read, rand.NewZipf
- import "math/rand"
-
+@@ -1183,6 +1178,62 @@
var _, _ = rand.Read, rand.NewZipf
-+`,
-+ },
+ `,
+ },
+ {
+ name: "comment_between_imports_simple",
+ in: `package main
@@ -106,47 +98,48 @@
+
+ _ "github.com/bar/foo2"
+)
- `,
- },
++`,
++ },
}
-diff --git a/internal/imports/sortimports.go b/internal/imports/sortimports.go
-index be8ffa25..25c5ca3f 100644
---- a/internal/imports/sortimports.go
-+++ b/internal/imports/sortimports.go
-@@ -34,14 +34,29 @@ func sortImports(localPrefix string, fset *token.FileSet, f *ast.File) {
+
+ func TestSimpleCases(t *testing.T) {
+Only in org_golang_x_tools/internal/imports: fix_test.go.orig
+diff -ur org_golang_x_tools.orig/internal/imports/sortimports.go org_golang_x_tools/internal/imports/sortimports.go
+--- org_golang_x_tools.orig/internal/imports/sortimports.go 2023-04-03 15:16:24.808998544 +0200
++++ org_golang_x_tools/internal/imports/sortimports.go 2023-04-03 15:20:31.361303687 +0200
+@@ -38,15 +38,31 @@
continue
}
+ // Find comments.
+ commentLines := make([]int, len(f.Comments))
+ for j, comment := range f.Comments {
-+ commentLines[j] = fset.Position(comment.Pos()).Line
++ commentLines[j] = tokFile.Line(comment.Pos())
+ }
+
// Identify and sort runs of specs on successive lines.
i := 0
specs := d.Specs[:0]
for j, s := range d.Specs {
-- if j > i && fset.Position(s.Pos()).Line > 1+fset.Position(d.Specs[j-1].End()).Line {
+- if j > i && tokFile.Line(s.Pos()) > 1+tokFile.Line(d.Specs[j-1].End()) {
- // j begins a new run. End this one.
-- specs = append(specs, sortSpecs(localPrefix, fset, f, d.Specs[i:j])...)
+- specs = append(specs, sortSpecs(localPrefix, tokFile, f, d.Specs[i:j])...)
- i = j
+ if j > i {
-+ curLine, prevLine := fset.Position(s.Pos()).Line, fset.Position(d.Specs[j-1].End()).Line
++ curLine, prevLine := tokFile.Line(s.Pos()), tokFile.Line(d.Specs[j-1].End())
+ if curLine > 1+prevLine {
+ // j begins a new run.
+ for _, commentLine := range commentLines {
+ if prevLine < commentLine && commentLine < curLine {
+ // End this one if there is a comment before the new one.
-+ specs = append(specs, sortSpecs(localPrefix, fset, f, d.Specs[i:j])...)
++ specs = append(specs, sortSpecs(localPrefix, tokFile, f, d.Specs[i:j])...)
+ i = j
+ break
+ }
+ }
+ }
}
++
}
- specs = append(specs, sortSpecs(localPrefix, fset, f, d.Specs[i:])...)
---
-2.31.1
-
+ specs = append(specs, sortSpecs(localPrefix, tokFile, f, d.Specs[i:])...)
+ d.Specs = specs