github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/cmd/go/testdata/script/mod_edit.txt (about)

     1  env GO111MODULE=on
     2  
     3  # Test that go mod edits and related mod flags work.
     4  # Also test that they can use a dummy name that isn't resolvable. golang.org/issue/24100
     5  
     6  # go mod init
     7  ! go mod init
     8  stderr 'cannot determine module path'
     9  ! exists go.mod
    10  
    11  go mod init x.x/y/z
    12  stderr 'creating new go.mod: module x.x/y/z'
    13  cmpenv go.mod $WORK/go.mod.init
    14  
    15  ! go mod init
    16  cmpenv go.mod $WORK/go.mod.init
    17  
    18  # go mod edits
    19  go mod edit -droprequire=x.1 -require=x.1@v1.0.0 -require=x.2@v1.1.0 -droprequire=x.2 -exclude='x.1 @ v1.2.0' -exclude=x.1@v1.2.1 -replace=x.1@v1.3.0=y.1@v1.4.0 -replace='x.1@v1.4.0 = ../z'
    20  cmpenv go.mod $WORK/go.mod.edit1
    21  go mod edit -droprequire=x.1 -dropexclude=x.1@v1.2.1 -dropreplace=x.1@v1.3.0 -require=x.3@v1.99.0
    22  cmpenv go.mod $WORK/go.mod.edit2
    23  
    24  # go mod edit -json
    25  go mod edit -json
    26  cmpenv stdout $WORK/go.mod.json
    27  
    28  # go mod edit -replace
    29  go mod edit -replace=x.1@v1.3.0=y.1/v2@v2.3.5 -replace=x.1@v1.4.0=y.1/v2@v2.3.5
    30  cmpenv go.mod $WORK/go.mod.edit3
    31  go mod edit -replace=x.1=y.1/v2@v2.3.6
    32  cmpenv go.mod $WORK/go.mod.edit4
    33  go mod edit -dropreplace=x.1
    34  cmpenv go.mod $WORK/go.mod.edit5
    35  
    36  # go mod edit -fmt
    37  cp $WORK/go.mod.badfmt go.mod
    38  go mod edit -fmt -print # -print should avoid writing file
    39  cmpenv stdout $WORK/go.mod.edit6
    40  cmp go.mod $WORK/go.mod.badfmt
    41  go mod edit -fmt # without -print, should write file (and nothing to stdout)
    42  ! stdout .
    43  cmpenv go.mod $WORK/go.mod.edit6
    44  
    45  # go mod edit -module
    46  cd $WORK/m
    47  go mod init a.a/b/c
    48  go mod edit -module x.x/y/z
    49  cmpenv go.mod go.mod.edit
    50  
    51  -- x.go --
    52  package x
    53  
    54  -- w/w.go --
    55  package w
    56  
    57  -- $WORK/go.mod.init --
    58  module x.x/y/z
    59  
    60  go $goversion
    61  -- $WORK/go.mod.edit1 --
    62  module x.x/y/z
    63  
    64  go $goversion
    65  
    66  require x.1 v1.0.0
    67  
    68  exclude (
    69  	x.1 v1.2.0
    70  	x.1 v1.2.1
    71  )
    72  
    73  replace (
    74  	x.1 v1.3.0 => y.1 v1.4.0
    75  	x.1 v1.4.0 => ../z
    76  )
    77  -- $WORK/go.mod.edit2 --
    78  module x.x/y/z
    79  
    80  go $goversion
    81  
    82  exclude x.1 v1.2.0
    83  
    84  replace x.1 v1.4.0 => ../z
    85  
    86  require x.3 v1.99.0
    87  -- $WORK/go.mod.json --
    88  {
    89  	"Module": {
    90  		"Path": "x.x/y/z"
    91  	},
    92  	"Go": "$goversion",
    93  	"Require": [
    94  		{
    95  			"Path": "x.3",
    96  			"Version": "v1.99.0"
    97  		}
    98  	],
    99  	"Exclude": [
   100  		{
   101  			"Path": "x.1",
   102  			"Version": "v1.2.0"
   103  		}
   104  	],
   105  	"Replace": [
   106  		{
   107  			"Old": {
   108  				"Path": "x.1",
   109  				"Version": "v1.4.0"
   110  			},
   111  			"New": {
   112  				"Path": "../z"
   113  			}
   114  		}
   115  	]
   116  }
   117  -- $WORK/go.mod.edit3 --
   118  module x.x/y/z
   119  
   120  go $goversion
   121  
   122  exclude x.1 v1.2.0
   123  
   124  replace (
   125  	x.1 v1.3.0 => y.1/v2 v2.3.5
   126  	x.1 v1.4.0 => y.1/v2 v2.3.5
   127  )
   128  
   129  require x.3 v1.99.0
   130  -- $WORK/go.mod.edit4 --
   131  module x.x/y/z
   132  
   133  go $goversion
   134  
   135  exclude x.1 v1.2.0
   136  
   137  replace x.1 => y.1/v2 v2.3.6
   138  
   139  require x.3 v1.99.0
   140  -- $WORK/go.mod.edit5 --
   141  module x.x/y/z
   142  
   143  go $goversion
   144  
   145  exclude x.1 v1.2.0
   146  
   147  require x.3 v1.99.0
   148  -- $WORK/go.mod.edit6 --
   149  module x.x/y/z
   150  
   151  go 1.10
   152  
   153  exclude x.1 v1.2.0
   154  
   155  replace x.1 => y.1/v2 v2.3.6
   156  
   157  require x.3 v1.99.0
   158  -- $WORK/go.mod.badfmt --
   159  module     x.x/y/z
   160  
   161  go 1.10
   162  
   163  exclude x.1     v1.2.0
   164  
   165  replace x.1    =>   y.1/v2 v2.3.6
   166  
   167  require x.3   v1.99.0
   168  -- $WORK/m/go.mod.edit --
   169  module x.x/y/z
   170  
   171  go $goversion