github.com/chenfeining/golangci-lint@v1.0.2-0.20230730162517-14c6c67868df/test/testdata/gomodguard.go (about)

     1  //golangcitest:args -Egomodguard
     2  //golangcitest:config_path testdata/configs/gomodguard.yml
     3  package testdata
     4  
     5  import (
     6  	"log"
     7  
     8  	"golang.org/x/mod/modfile"
     9  	"gopkg.in/yaml.v3" // want "import of package `gopkg.in/yaml.v3` is blocked because the module is in the blocked modules list. `github.com/kylelemons/go-gypsy` is a recommended module. This is an example of recommendations."
    10  )
    11  
    12  // Something just some struct
    13  type Something struct{}
    14  
    15  func aAllowedImport() { //nolint:unused
    16  	mfile, _ := modfile.Parse("go.mod", []byte{}, nil)
    17  
    18  	log.Println(mfile)
    19  }
    20  
    21  func aBlockedImport() { //nolint:unused
    22  	data := []byte{}
    23  	something := Something{}
    24  	_ = yaml.Unmarshal(data, &something)
    25  
    26  	log.Println(data)
    27  }