Home | History | Annotate | Download | only in whitelist
      1 // Copyright 2013 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 // Package whitelist defines exceptions for the vet tool.
      6 package whitelist // import "cmd/vet/whitelist"
      7 
      8 // UnkeyedLiteral are types that are actually slices, but
      9 // syntactically, we cannot tell whether the Typ in pkg.Typ{1, 2, 3}
     10 // is a slice or a struct, so we whitelist all the standard package
     11 // library's exported slice types.
     12 var UnkeyedLiteral = map[string]bool{
     13 	/*
     14 		find $GOROOT/src -type f | grep -v _test.go | xargs grep '^type.*\[\]' | \
     15 			grep -v ' map\[' | sed 's,/[^/]*go.type,,' | sed 's,.*src/,,' | \
     16 			sed 's, ,.,' |  sed 's, .*,,' | grep -v '\.[a-z]' | \
     17 			sort | awk '{ print "\"" $0 "\": true," }'
     18 	*/
     19 	"crypto/x509/pkix.RDNSequence":                  true,
     20 	"crypto/x509/pkix.RelativeDistinguishedNameSET": true,
     21 	"database/sql.RawBytes":                         true,
     22 	"debug/macho.LoadBytes":                         true,
     23 	"encoding/asn1.ObjectIdentifier":                true,
     24 	"encoding/asn1.RawContent":                      true,
     25 	"encoding/json.RawMessage":                      true,
     26 	"encoding/xml.CharData":                         true,
     27 	"encoding/xml.Comment":                          true,
     28 	"encoding/xml.Directive":                        true,
     29 	"go/scanner.ErrorList":                          true,
     30 	"image/color.Palette":                           true,
     31 	"net.HardwareAddr":                              true,
     32 	"net.IP":                                        true,
     33 	"net.IPMask":                                    true,
     34 	"sort.Float64Slice":                             true,
     35 	"sort.IntSlice":                                 true,
     36 	"sort.StringSlice":                              true,
     37 	"unicode.SpecialCase":                           true,
     38 
     39 	// These image and image/color struct types are frozen. We will never add fields to them.
     40 	"image/color.Alpha16": true,
     41 	"image/color.Alpha":   true,
     42 	"image/color.CMYK":    true,
     43 	"image/color.Gray16":  true,
     44 	"image/color.Gray":    true,
     45 	"image/color.NRGBA64": true,
     46 	"image/color.NRGBA":   true,
     47 	"image/color.RGBA64":  true,
     48 	"image/color.RGBA":    true,
     49 	"image/color.YCbCr":   true,
     50 	"image.Point":         true,
     51 	"image.Rectangle":     true,
     52 	"image.Uniform":       true,
     53 }
     54