@@ -31,9 +31,9 @@ func getRangeAndPeriod(dateRange, dateFreq string) (start, end time.Time, period
3131func getAccounts (accountNeedle string , accountsHaystack []* ledger.Account ) (results []* ledger.Account ) {
3232 needleDepth := len (strings .Split (accountNeedle , ":" ))
3333
34- if dblstarIdx := strings .Index (accountNeedle , "**" ); dblstarIdx != - 1 {
34+ if before , _ , ok := strings .Cut (accountNeedle , "**" ); ok {
3535 foundAccountNames := make (map [string ]* ledger.Account )
36- prefixNeedle := accountNeedle [: dblstarIdx ]
36+ prefixNeedle := before
3737 for _ , hay := range accountsHaystack {
3838 if strings .HasPrefix (hay .Name , prefixNeedle ) {
3939 foundAccountNames [hay .Name ] = hay
@@ -48,8 +48,8 @@ func getAccounts(accountNeedle string, accountsHaystack []*ledger.Account) (resu
4848 for _ , hay := range foundAccountNames {
4949 results = append (results , hay )
5050 }
51- } else if starIdx := strings .Index (accountNeedle , "*" ); starIdx != - 1 {
52- prefixNeedle := accountNeedle [: starIdx ]
51+ } else if before , _ , ok := strings .Cut (accountNeedle , "*" ); ok {
52+ prefixNeedle := before
5353 for _ , hay := range accountsHaystack {
5454 hayDepth := len (strings .Split (hay .Name , ":" ))
5555 if strings .HasPrefix (hay .Name , prefixNeedle ) && hayDepth == needleDepth {
0 commit comments