Skip to content

Commit

Permalink
refactor: use strings.Cut to simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Feb 17, 2025
1 parent fb8aa1d commit 2029668
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions musttag.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,11 @@ func implementsInterface(typ types.Type, ifaces []string, imports []*types.Packa

for _, ifacePath := range ifaces {
// e.g. "encoding/json.Marshaler" -> "encoding/json" + "Marshaler".
idx := strings.LastIndex(ifacePath, ".")
if idx == -1 {
pkgName, ifaceName, ok := strings.Cut(ifacePath, ".")
if !ok {
continue
}

pkgName, ifaceName := ifacePath[:idx], ifacePath[idx+1:]

scope, ok := findScope(pkgName)
if !ok {
continue
Expand Down

0 comments on commit 2029668

Please sign in to comment.