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

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

View as plain text