fix some go errors/warnings

This commit is contained in:
sawka 2023-12-05 10:43:49 -08:00
parent 6791d874e3
commit 724a68393a
3 changed files with 14 additions and 10 deletions

View File

@ -1591,7 +1591,7 @@ func CrCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.Up
if noHist {
screen, err := sstore.GetScreenById(ctx, ids.ScreenId)
if err != nil {
return nil, fmt.Errorf("/% error: cannot resolve screen for update: %w", err)
return nil, fmt.Errorf("/%s error: cannot resolve screen for update: %w", GetCmdStr(pk), err)
}
update := &sstore.ModelUpdate{
Screens: []*sstore.ScreenType{screen},

View File

@ -7,10 +7,12 @@ import (
"fmt"
"os"
"testing"
"github.com/wavetermdev/waveterm/wavesrv/pkg/rtnstate"
)
func xTestParseAliases(t *testing.T) {
m, err := ParseAliases(`
m, err := rtnstate.ParseAliases(`
alias cdg='cd work/gopath/src/github.com/sawka'
alias s='scripthaus'
alias x='ls;ls"'
@ -29,7 +31,7 @@ func xTestParseFuncs(t *testing.T) {
if err != nil {
t.Fatalf("error reading linux-decls: %v", err)
}
m, err := ParseFuncs(string(file))
m, err := rtnstate.ParseFuncs(string(file))
if err != nil {
t.Fatalf("error parsing funcs: %v", err)
}

View File

@ -7,19 +7,21 @@ import (
"fmt"
"strings"
"testing"
"github.com/wavetermdev/waveterm/wavesrv/pkg/utilfn"
)
func parseToSP(s string) StrWithPos {
func parseToSP(s string) utilfn.StrWithPos {
idx := strings.Index(s, "[*]")
if idx == -1 {
return StrWithPos{Str: s}
return utilfn.StrWithPos{Str: s}
}
return StrWithPos{Str: s[0:idx] + s[idx+3:], Pos: idx}
return utilfn.StrWithPos{Str: s[0:idx] + s[idx+3:], Pos: idx}
}
func testParse(cmdStr string, pos int) {
fmt.Printf("cmd: %s\n", strWithCursor(cmdStr, pos))
p := ParseCompPoint(StrWithPos{Str: cmdStr, Pos: pos})
fmt.Printf("cmd: %s\n", utilfn.StrWithPos{Str: cmdStr, Pos: pos})
p := ParseCompPoint(utilfn.StrWithPos{Str: cmdStr, Pos: pos})
p.dump()
}
@ -64,9 +66,9 @@ func Test2(t *testing.T) {
testMiniExtend(t, p, "foo's", true, `$'foo\'s[*]more`)
}
func testParseRT(t *testing.T, origSP StrWithPos) {
func testParseRT(t *testing.T, origSP utilfn.StrWithPos) {
p := ParseCompPoint(origSP)
newSP := StrWithPos{Str: p.getOrigStr(), Pos: p.getOrigPos()}
newSP := utilfn.StrWithPos{Str: p.getOrigStr(), Pos: p.getOrigPos()}
if origSP != newSP {
t.Fatalf("not equal: [%s] != [%s]", origSP, newSP)
}