Skip to content

Commit 4a32fb0

Browse files
committed
Use strings.TrimSuffix instead of replaceRight
1 parent 1a94dbf commit 4a32fb0

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

macaroon_recipes.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,6 @@ var (
5555
}
5656
)
5757

58-
func replaceRight(s, oldString, newString string) string {
59-
i := strings.LastIndex(s, oldString)
60-
if i == -1 {
61-
return s
62-
}
63-
64-
return s[:i] + newString + s[i+len(oldString):]
65-
}
66-
6758
// MacaroonRecipe returns a list of macaroon permissions that is required to use
6859
// the full feature set of the given list of RPC package names.
6960
func MacaroonRecipe(c LightningClient, packages []string) ([]MacaroonPermission,
@@ -87,7 +78,7 @@ func MacaroonRecipe(c LightningClient, packages []string) ([]MacaroonPermission,
8778
// From the pointer type we can find out the interface, its name
8879
// and what methods it declares.
8980
ifaceType := reflect.TypeOf(ifacePtr).Elem()
90-
serverName := replaceRight(ifaceType.Name(), "Client", "")
81+
serverName := strings.TrimSuffix(ifaceType.Name(), "Client")
9182
for i := range ifaceType.NumMethod() {
9283
// The methods in lndclient might be called slightly
9384
// differently. Rename according to our rename mapping

0 commit comments

Comments
 (0)