...

Text file src/cmd/go/testdata/script/mod_sumdb_golang.txt

Documentation: cmd/go/testdata/script

     1# Test default GOPROXY and GOSUMDB
     2[go-builder] env GOPROXY=
     3[go-builder] env GOSUMDB=
     4[go-builder] go env GOPROXY
     5[go-builder] stdout '^https://proxy.golang.org,direct$'
     6[go-builder] go env GOSUMDB
     7[go-builder] stdout '^sum.golang.org$'
     8[go-builder] env GOPROXY=https://proxy.golang.org
     9[go-builder] go env GOSUMDB
    10[go-builder] stdout '^sum.golang.org$'
    11
    12# Download direct from github.
    13
    14[!net:proxy.golang.org] skip
    15[!net:sum.golang.org] skip
    16[!git] skip
    17env GOSUMDB=sum.golang.org
    18env GOPROXY=direct
    19
    20go get rsc.io/quote@v1.5.2
    21cp go.sum saved.sum
    22
    23
    24# Download from proxy.golang.org with go.sum entry already.
    25# Use 'go list' instead of 'go get' since the latter may download extra go.mod
    26# files not listed in go.sum.
    27
    28go clean -modcache
    29env GOSUMDB=sum.golang.org
    30env GOPROXY=https://proxy.golang.org,direct
    31
    32go list -x -m all  # Download go.mod files.
    33! stderr github
    34stderr proxy.golang.org/rsc.io/quote
    35! stderr sum.golang.org/tile
    36! stderr sum.golang.org/lookup/rsc.io/quote
    37
    38go list -x -deps rsc.io/quote  # Download module source.
    39! stderr github
    40stderr proxy.golang.org/rsc.io/quote
    41! stderr sum.golang.org/tile
    42! stderr sum.golang.org/lookup/rsc.io/quote
    43
    44cmp go.sum saved.sum
    45
    46
    47# Download again.
    48# Should use the checksum database to validate new go.sum lines,
    49# but not need to fetch any new data from the proxy.
    50
    51rm go.sum
    52
    53go list -mod=mod -x -m all  # Add checksums for go.mod files.
    54stderr sum.golang.org/tile
    55! stderr github
    56! stderr proxy.golang.org/rsc.io/quote
    57stderr sum.golang.org/lookup/rsc.io/quote
    58
    59go list -mod=mod -x rsc.io/quote  # Add checksums for module source.
    60! stderr .  # Adds checksums, but for entities already in the module cache.
    61
    62cmp go.sum saved.sum
    63
    64
    65# test fallback to direct
    66
    67env TESTGOPROXY404=1
    68go clean -modcache
    69rm go.sum
    70
    71go list -mod=mod -x -m all  # Download go.mod files
    72stderr 'proxy.golang.org.*404 testing'
    73stderr github.com/rsc
    74
    75go list -mod=mod -x rsc.io/quote  # Download module source.
    76stderr 'proxy.golang.org.*404 testing'
    77stderr github.com/rsc
    78
    79cmp go.sum saved.sum
    80
    81
    82-- go.mod --
    83module m

View as plain text