Skip to content

Commit

Permalink
cmd/modinfo/internal/pkgsitedb: fix build on plan9
Browse files Browse the repository at this point in the history
Package pkgsitedb doesn't work on plan9 because a dependency doesn't
support it. It was meant to return a runtime error in the db_plan9.go
implementation, but it looks like there was a mixup with a similar
pkgsitedb package at golang.org/x/pkgsite-metrics/internal/pkgsitedb.

After these changes, it and all of its tests compile on GOOS=plan9:

$ GOOS=plan9 GOARCH=amd64 go test -c -o=/dev/null ./...
[...]
$ echo $?
0

Also run 'go mod tidy' to drop the x/pkgsite-metric requirement.

For golang/go#61698.

Change-Id: Ia016b5705894029380840ce8499047e264054e9f
Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/518095
Reviewed-by: Dmitri Shuralyov <[email protected]>
Run-TryBot: Dmitri Shuralyov <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Auto-Submit: Dmitri Shuralyov <[email protected]>
Reviewed-by: Jonathan Amsterdam <[email protected]>
  • Loading branch information
dmitshur authored and gopherbot committed Aug 10, 2023
1 parent 21b1797 commit 8f45533
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
27 changes: 22 additions & 5 deletions cmd/modinfo/internal/pkgsitedb/db_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,34 @@ import (
"context"
"database/sql"
"errors"

"golang.org/x/pkgsite-metrics/internal/config"
"golang.org/x/pkgsite-metrics/internal/scan"
)

var errDoesNotCompile = errors.New("github.com/lib/pq does not compile on plan9")

func Open(ctx context.Context, cfg *config.Config) (_ *sql.DB, err error) {
type Config struct {
User string
PasswordSecret string
Password string
Host string
Port string
DBName string
}

func Open(ctx context.Context, cfg Config) (_ *sql.DB, err error) {
return nil, errDoesNotCompile
}

func ModuleSpecs(ctx context.Context, db *sql.DB, minImportedByCount int) (specs []scan.ModuleSpec, err error) {
type Module struct {
Path string
Packages []*Package
}

type Package struct {
Path string
Version string
NumImporters int
}

func QueryModule(ctx context.Context, db *sql.DB, modulePath string) (*Module, error) {
return nil, errDoesNotCompile
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ require (
golang.org/x/exp/event v0.0.0-20220218215828-6cf2b201936e
golang.org/x/mod v0.10.0
golang.org/x/oauth2 v0.8.0
golang.org/x/pkgsite-metrics v0.0.0-20230724182206-f4d26a684cbf
golang.org/x/sync v0.2.0
golang.org/x/time v0.1.0
golang.org/x/tools v0.9.3
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,6 @@ golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8=
golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE=
golang.org/x/pkgsite-metrics v0.0.0-20230724182206-f4d26a684cbf h1:EZsyqK8LLPSx01Tr2yXk66Vcp/1yDCw3x58dbi1xTqA=
golang.org/x/pkgsite-metrics v0.0.0-20230724182206-f4d26a684cbf/go.mod h1:0Jrcyk3p5rHS8+NbicrlGT3w+0hmXv2mBLXqkv6ySXs=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down

0 comments on commit 8f45533

Please sign in to comment.