Black Lives Matter. Support the Equal Justice Initiative.

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

Documentation: cmd/go/testdata/script

     1  go mod vendor
     2  cmp vendor/example.com/a/samedir_embed.txt a/samedir_embed.txt
     3  cmp vendor/example.com/a/subdir/embed.txt a/subdir/embed.txt
     4  cmp vendor/example.com/a/subdir/test/embed.txt a/subdir/test/embed.txt
     5  cmp vendor/example.com/a/subdir/test/xtest/embed.txt a/subdir/test/xtest/embed.txt
     6  
     7  cd broken_no_matching_files
     8  ! go mod vendor
     9  stderr 'go mod vendor: pattern foo.txt: no matching files found'
    10  
    11  cd ../broken_bad_pattern
    12  ! go mod vendor
    13  stderr 'go mod vendor: pattern ../foo.txt: invalid pattern syntax'
    14  
    15  # matchPotentialSourceFile prunes out tests and unbuilt code.
    16  # Make sure that they are vendored if they are embedded files.
    17  cd ../embed_unbuilt
    18  go mod vendor
    19  cmp vendor/example.com/dep/unbuilt.go dep/unbuilt.go
    20  cmp vendor/example.com/dep/dep_test.go dep/dep_test.go
    21  ! exists vendor/example.com/dep/not_embedded_unbuilt.go
    22  ! exists vendor/example.com/dep/not_embedded_dep_test.go
    23  -- go.mod --
    24  module example.com/foo
    25  go 1.16
    26  
    27  require (
    28  	example.com/a v0.1.0
    29  )
    30  
    31  replace (
    32  	example.com/a v0.1.0 => ./a
    33  )
    34  -- foo.go --
    35  package main
    36  
    37  import (
    38  	"fmt"
    39  
    40  	"example.com/a"
    41  )
    42  
    43  func main() {
    44      fmt.Println(a.Str())
    45  }
    46  -- a/go.mod --
    47  module example.com/a
    48  -- a/a.go --
    49  package a
    50  
    51  import _ "embed"
    52  
    53  //go:embed samedir_embed.txt
    54  var sameDir string
    55  
    56  //go:embed subdir/embed.txt
    57  var subDir string
    58  
    59  func Str() string {
    60  	return sameDir + subDir
    61  }
    62  -- a/a_test.go --
    63  package a
    64  
    65  import _ "embed"
    66  
    67  //go:embed subdir/test/embed.txt
    68  var subderTest string
    69  -- a/a_x_test.go --
    70  package a_test
    71  
    72  import _ "embed"
    73  
    74  //go:embed subdir/test/xtest/embed.txt
    75  var subdirXtest string
    76  -- a/samedir_embed.txt --
    77  embedded file in same directory as package
    78  -- a/subdir/embed.txt --
    79  embedded file in subdirectory of package
    80  -- a/subdir/test/embed.txt --
    81  embedded file of test in subdirectory of package
    82  -- a/subdir/test/xtest/embed.txt --
    83  embedded file of xtest in subdirectory of package
    84  -- broken_no_matching_files/go.mod --
    85  module example.com/broken
    86  go 1.16
    87  
    88  require (
    89  	example.com/brokendep v0.1.0
    90  )
    91  
    92  replace (
    93  	example.com/brokendep v0.1.0 => ./brokendep
    94  )
    95  -- broken_no_matching_files/f.go --
    96  package broken
    97  
    98  import _ "example.com/brokendep"
    99  
   100  func F() {}
   101  -- broken_no_matching_files/brokendep/go.mod --
   102  module example.com/brokendep
   103  go 1.16
   104  -- broken_no_matching_files/brokendep/f.go --
   105  package brokendep
   106  
   107  import _ "embed"
   108  
   109  //go:embed foo.txt
   110  var foo string
   111  -- broken_bad_pattern/go.mod --
   112  module example.com/broken
   113  go 1.16
   114  
   115  require (
   116  	example.com/brokendep v0.1.0
   117  )
   118  
   119  replace (
   120  	example.com/brokendep v0.1.0 => ./brokendep
   121  )
   122  -- broken_bad_pattern/f.go --
   123  package broken
   124  
   125  import _ "example.com/brokendep"
   126  
   127  func F() {}
   128  -- broken_bad_pattern/brokendep/go.mod --
   129  module example.com/brokendep
   130  go 1.16
   131  -- broken_bad_pattern/brokendep/f.go --
   132  package brokendep
   133  
   134  import _ "embed"
   135  
   136  //go:embed ../foo.txt
   137  var foo string
   138  -- embed_unbuilt/go.mod --
   139  module example.com/foo
   140  go 1.16
   141  
   142  require (
   143  	example.com/dep v0.1.0
   144  )
   145  
   146  replace (
   147  	example.com/dep v0.1.0 => ./dep
   148  )
   149  -- embed_unbuilt/foo.go --
   150  package a
   151  
   152  import _ "example.com/dep"
   153  
   154  func F() {}
   155  -- embed_unbuilt/dep/go.mod --
   156  module example.com/dep
   157  go 1.16
   158  -- embed_unbuilt/dep/dep.go --
   159  package dep
   160  
   161  import _ "embed"
   162  
   163  //go:embed unbuilt.go
   164  var unbuilt string
   165  
   166  //go:embed dep_test.go
   167  var depTest string
   168  -- embed_unbuilt/dep/unbuilt.go --
   169  // +build ignore
   170  
   171  package dep
   172  -- embed_unbuilt/dep/not_embedded_unbuilt.go --
   173  // +build ignore
   174  
   175  package dep
   176  -- embed_unbuilt/dep/dep_test.go --
   177  package dep
   178  -- embed_unbuilt/dep/not_embedded_dep_test.go --
   179  package dep
   180  

View as plain text