github.com/vanstinator/golangci-lint@v0.0.0-20240223191551-cc572f00d9d1/test/testdata/musttag.go (about)

     1  //golangcitest:args -Emusttag
     2  package testdata
     3  
     4  import (
     5  	"encoding/asn1"
     6  	"encoding/json"
     7  )
     8  
     9  // builtin functions:
    10  func musttagJSON() {
    11  	var user struct {
    12  		Name  string
    13  		Email string `json:"email"`
    14  	}
    15  	json.Marshal(user) // want "the given struct should be annotated with the `json` tag"
    16  }
    17  
    18  // custom functions from config:
    19  func musttagASN1() {
    20  	var user struct {
    21  		Name  string
    22  		Email string `asn1:"email"`
    23  	}
    24  	asn1.Marshal(user)
    25  }