From 1798a1540ce75d065be122183c526d1a8e7ae27f Mon Sep 17 00:00:00 2001 From: Peachpit Date: Sun, 17 Nov 2024 05:16:15 -0800 Subject: [PATCH] Add use of gocode keyword to mute tuplifying returns --- source/service/golang.go | 11 +++++++---- source/service/rsc/pipefish/world.pf | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/service/golang.go b/source/service/golang.go index d979bf5a..23cf89f3 100644 --- a/source/service/golang.go +++ b/source/service/golang.go @@ -294,7 +294,7 @@ func doctorReturns(body string) string { output := "" for ix := strings.Index(body, "return "); ix != -1; ix = strings.Index(body, "return ") { - output = output + body[:ix] + "return tuplify(" + output = output + body[:ix] body = body[ix+7:] @@ -305,7 +305,7 @@ func doctorReturns(body string) string { if lineEnd == -1 { panic("Tim, you goofed. Lines are meant to have endings.") } - newLine := strings.TrimRight(body[:lineEnd], "\n\r \t") + newLine := strings.Trim(body[:lineEnd], "\n\r \t") if returnBody != "" { returnBody = returnBody + "\n" } @@ -321,8 +321,11 @@ func doctorReturns(body string) string { } body = body[ix:] - output = output + returnBody + ")" - + if len(returnBody) >= 7 && returnBody[:7] == "gocode" { + output = output + "return " + returnBody + } else { + output = output + "return tuplify(" + returnBody + ")" + } } return output + body diff --git a/source/service/rsc/pipefish/world.pf b/source/service/rsc/pipefish/world.pf index b289d6e0..581e7adb 100644 --- a/source/service/rsc/pipefish/world.pf +++ b/source/service/rsc/pipefish/world.pf @@ -171,12 +171,12 @@ goGetDirectoryNames(directoryNames DirectoryNames) : gocode { } err := filepath.Walk(directoryNames.directory, func(path string, info os.FileInfo, err error) error { if err != nil { - return err + return gocode err } if info.IsDir() { resultList = append(resultList, info.Name()) } - return nil + return gocode nil }) if err != nil { return err