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: Bump Go version 1.23.0 -> 1.23.1 #128

Merged
merged 2 commits into from
Sep 6, 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
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
golang 1.23.0
golang 1.23.1
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
# <other stuff to ignore>
# And use this digest in FROM

ARG base_sha=8e529b64d382182bb84f201dea3c72118f6ae9bc01d27190ffc5a54acf0091d2
ARG base_sha=b46e8734b39f93a584eae135fc545edfdee99f1fb55c077fca908a15eb07010c

FROM golang:1.23.0@sha256:${base_sha} as builder
FROM golang:1.23.1@sha256:${base_sha} as builder

COPY . /sources
WORKDIR /sources
RUN go build -o scip-go ./cmd/scip-go

# Keep in sync with builder image
FROM golang:1.23.0@sha256:${base_sha} as final
FROM golang:1.23.1@sha256:${base_sha} as final

COPY --from=builder /sources/scip-go /usr/bin/
CMD ["scip-go"]
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/sourcegraph/scip-go

go 1.23
go 1.23.1

require (
github.com/charmbracelet/log v0.4.0
Expand Down
45 changes: 34 additions & 11 deletions internal/document/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import (
"go/doc"
"go/token"
"go/types"
"os"
"strings"
"sync"

"github.com/charmbracelet/log"
"github.com/sourcegraph/scip-go/internal/lookup"
"github.com/sourcegraph/scip-go/internal/symbols"
"github.com/sourcegraph/scip/bindings/go/scip"
Expand Down Expand Up @@ -169,7 +172,6 @@ func typeStringForObject(obj types.Object) (signature string, extra string) {

case *types.Const:
return fmt.Sprintf("%s = %s", types.ObjectString(v, packageQualifier), v.Val()), ""

// TODO: We had this case in previous iterations
// case *PkgDeclaration:
// return fmt.Sprintf("package %s", v.name), ""
Expand All @@ -181,23 +183,44 @@ func typeStringForObject(obj types.Object) (signature string, extra string) {
return types.ObjectString(obj, packageQualifier), ""
}

var loggedGODEBUGWarning sync.Once

// formatTypeSignature returns a brief description of the given struct or interface type.
func formatTypeSignature(obj *types.TypeName) string {
switch obj.Type().Underlying().(type) {
case *types.Struct:
if obj.IsAlias() {
switch obj.Type().(type) {
case *types.Named:
original := obj.Type().(*types.Named).Obj()
var pkg string
if obj.Pkg().Name() != original.Pkg().Name() {
pkg = original.Pkg().Name() + "."
switch ty := obj.Type().(type) {
case *types.Alias:
switch rhs := ty.Rhs().(type) {
case *types.Alias:
original := rhs.Obj()
var pkg string
if obj.Pkg().Name() != original.Pkg().Name() {
pkg = original.Pkg().Name() + "."
}
return fmt.Sprintf("type %s = %s%s", obj.Name(), pkg, original.Name())
case *types.Named:
original := rhs.Obj()
var pkg string
if obj.Pkg().Name() != original.Pkg().Name() {
pkg = original.Pkg().Name() + "."
}
return fmt.Sprintf("type %s = %s%s", obj.Name(), pkg, original.Name())
case *types.Struct:
return fmt.Sprintf("type %s = struct", obj.Name())
}
default:
if val := os.Getenv("GODEBUG"); strings.Contains(val, "gotypealias=0") {
loggedGODEBUGWarning.Do(func() {
log.Warn("Running with GODEBUG=gotypealias=0, this may cause incorrect hover docs")
})
} else {
log.Warn("IsAlias() is true but Type() is not Alias; please report this as a bug",
"obj", obj.String(), "obj.Type()", ty.String())
}
return fmt.Sprintf("type %s = %s%s", obj.Name(), pkg, original.Name())

case *types.Struct:
return fmt.Sprintf("type %s = struct", obj.Name())
}

}

return fmt.Sprintf("type %s struct", obj.Name())
Expand Down
7 changes: 0 additions & 7 deletions internal/index/scip.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
_ "embed"
"fmt"
"go/ast"
"os"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -88,12 +87,6 @@ func ListMissing(opts config.IndexOpts) (missing []string, err error) {
}

func Index(writer func(proto.Message), opts config.IndexOpts) error {
if os.Getenv("GODEBUG") == "" {
// TODO: Remove this after upgrading to Go 1.23.1
// See https://github.com/golang/go/issues/68894
os.Setenv("GODEBUG", "gotypesalias=0")
}

// Emit Metadata.
// NOTE: Must be the first field emitted
writer(&scip.Metadata{
Expand Down
2 changes: 1 addition & 1 deletion internal/loader/stdlib.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// THIS FILE IS GENERATED. SEE ./scripts/gen_std_lib.sh
// Generated by: go version go1.23.0 darwin/arm64
// Generated by: go version go1.23.1 darwin/arm64
package loader

var contained = struct{}{}
Expand Down
4 changes: 4 additions & 0 deletions internal/testdata/snapshots/input/alias/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ package main
type (
T struct{}
U = T
V = U
S U
Z int32
)

func f(u U) {}
32 changes: 32 additions & 0 deletions internal/testdata/snapshots/output/alias/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@
// > struct{}
// > ```
// ^ reference github.com/sourcegraph/scip-go . `github.com/sourcegraph/scip-go/internal/testdata/snapshots/input/alias`/T#
V = U
// ^ definition github.com/sourcegraph/scip-go . `github.com/sourcegraph/scip-go/internal/testdata/snapshots/input/alias`/V#
// documentation
// > ```go
// > type V = U
// > ```
// documentation
// > Check that we don't panic
// > Copied from https://github.com/golang/go/issues/68877#issuecomment-2290000187
// documentation
// > ```go
// > struct{}
// > ```
// ^ reference github.com/sourcegraph/scip-go . `github.com/sourcegraph/scip-go/internal/testdata/snapshots/input/alias`/U#
S U
// ^ definition github.com/sourcegraph/scip-go . `github.com/sourcegraph/scip-go/internal/testdata/snapshots/input/alias`/S#
// documentation
Expand All @@ -47,5 +61,23 @@
// > struct{}
// > ```
// ^ reference github.com/sourcegraph/scip-go . `github.com/sourcegraph/scip-go/internal/testdata/snapshots/input/alias`/U#
Z int32
// ^ definition github.com/sourcegraph/scip-go . `github.com/sourcegraph/scip-go/internal/testdata/snapshots/input/alias`/Z#
// documentation
// > Check that we don't panic
// > Copied from https://github.com/golang/go/issues/68877#issuecomment-2290000187
// documentation
// > ```go
// > int32
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the bug in #107 -- it's bizarre that this was not handled when the original switch was written, but trying to not fix that here for now, will do that in a follow-up PR

// > ```
)

func f(u U) {}
// ^ definition github.com/sourcegraph/scip-go . `github.com/sourcegraph/scip-go/internal/testdata/snapshots/input/alias`/f().
// documentation
// > ```go
// > func f(u U)
// > ```
// ^ definition local 0
// ^ reference github.com/sourcegraph/scip-go . `github.com/sourcegraph/scip-go/internal/testdata/snapshots/input/alias`/U#

Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@
// > ```go
// > func (T1).F1()
// > ```
// relationship 0.1.test `sg/testdata`/I1#F1. implementation
// relationship 0.1.test `sg/testdata`/I1#F1. implementation
// relationship 0.1.test `sg/testdata`/I1#F1. implementation

type T2 int
Expand Down Expand Up @@ -106,15 +104,13 @@
// > ```go
// > int
// > ```
// relationship 0.1.test `sg/testdata`/I1# implementation
// ^^ reference 0.1.test `sg/testdata`/T1#
type A12 = A1
// ^^^ definition 0.1.test `sg/testdata`/A12#
// documentation
// > ```go
// > int
// > ```
// relationship 0.1.test `sg/testdata`/I1# implementation
// ^^ reference 0.1.test `sg/testdata`/A1#

type InterfaceWithNonExportedMethod interface {
Expand Down
Loading