golang.org/x/tools/gopls@v0.15.3/internal/vulncheck/vulntest/stdlib.go (about) 1 // Copyright 2022 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 //go:build go1.18 6 // +build go1.18 7 8 package vulntest 9 10 import ( 11 "strings" 12 13 "golang.org/x/mod/module" 14 ) 15 16 // maybeStdlib reports whether the given import path could be part of the Go 17 // standard library, by reporting whether the first component lacks a '.'. 18 func maybeStdlib(path string) bool { 19 if err := module.CheckImportPath(path); err != nil { 20 return false 21 } 22 if i := strings.IndexByte(path, '/'); i != -1 { 23 path = path[:i] 24 } 25 return !strings.Contains(path, ".") 26 }