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

     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
    17  env GOSUMDB=sum.golang.org
    18  env GOPROXY=direct
    19  
    20  go get rsc.io/quote@v1.5.2
    21  cp 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  
    28  go clean -modcache
    29  env GOSUMDB=sum.golang.org
    30  env GOPROXY=https://proxy.golang.org,direct
    31  
    32  go list -x -m all  # Download go.mod files.
    33  ! stderr github
    34  stderr proxy.golang.org/rsc.io/quote
    35  ! stderr sum.golang.org/tile
    36  ! stderr sum.golang.org/lookup/rsc.io/quote
    37  
    38  go list -x -deps rsc.io/quote  # Download module source.
    39  ! stderr github
    40  stderr proxy.golang.org/rsc.io/quote
    41  ! stderr sum.golang.org/tile
    42  ! stderr sum.golang.org/lookup/rsc.io/quote
    43  
    44  cmp 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  
    51  rm go.sum
    52  
    53  go list -mod=mod -x -m all  # Add checksums for go.mod files.
    54  stderr sum.golang.org/tile
    55  ! stderr github
    56  ! stderr proxy.golang.org/rsc.io/quote
    57  stderr sum.golang.org/lookup/rsc.io/quote
    58  
    59  go 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  
    62  cmp go.sum saved.sum
    63  
    64  
    65  # test fallback to direct
    66  
    67  env TESTGOPROXY404=1
    68  go clean -modcache
    69  rm go.sum
    70  
    71  go list -mod=mod -x -m all  # Download go.mod files
    72  stderr 'proxy.golang.org.*404 testing'
    73  stderr github.com/rsc
    74  
    75  go list -mod=mod -x rsc.io/quote  # Download module source.
    76  stderr 'proxy.golang.org.*404 testing'
    77  stderr github.com/rsc
    78  
    79  cmp go.sum saved.sum
    80  
    81  
    82  -- go.mod --
    83  module m
    84  

View as plain text