package analyzers import "testing" func TestInferImportName(t *testing.T) { tests := []struct { path string want string }{ {path: "fmt", want: "fmt"}, {path: "gopkg.in/yaml.v3", want: "yaml"}, {path: "github.com/gocolly/colly/v2", want: "colly"}, {path: "golang.org/x/tools/go/packages", want: "packages"}, } for _, tt := range tests { got := inferImportName(tt.path) if got != tt.want { t.Fatalf("inferImportName(%q) = %q, want %q", tt.path, got, tt.want) } } }