From 724a68393a539d4f882828614671ed5468e8a05a Mon Sep 17 00:00:00 2001 From: sawka Date: Tue, 5 Dec 2023 10:43:49 -0800 Subject: [PATCH] fix some go errors/warnings --- wavesrv/pkg/cmdrunner/cmdrunner.go | 2 +- wavesrv/pkg/cmdrunner/shparse_test.go | 6 ++++-- wavesrv/pkg/comp/comp_test.go | 16 +++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/wavesrv/pkg/cmdrunner/cmdrunner.go b/wavesrv/pkg/cmdrunner/cmdrunner.go index fe48c682..0742fc13 100644 --- a/wavesrv/pkg/cmdrunner/cmdrunner.go +++ b/wavesrv/pkg/cmdrunner/cmdrunner.go @@ -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}, diff --git a/wavesrv/pkg/cmdrunner/shparse_test.go b/wavesrv/pkg/cmdrunner/shparse_test.go index 03b4ebc9..3608b072 100644 --- a/wavesrv/pkg/cmdrunner/shparse_test.go +++ b/wavesrv/pkg/cmdrunner/shparse_test.go @@ -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) } diff --git a/wavesrv/pkg/comp/comp_test.go b/wavesrv/pkg/comp/comp_test.go index 332ff1f6..e9866201 100644 --- a/wavesrv/pkg/comp/comp_test.go +++ b/wavesrv/pkg/comp/comp_test.go @@ -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) }