From d0a8bacab612ae2ecae3525fb7548f1c5e6ed35d Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 22 May 2018 14:10:13 -0400 Subject: Use proto2 instead of proto3 Travis doesn't support proto3. --- os.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'os.go') diff --git a/os.go b/os.go index 214492eea..59c24ccdf 100644 --- a/os.go +++ b/os.go @@ -16,14 +16,14 @@ func InitOS() { switch msg.Payload.(type) { case *Msg_Exit: payload := msg.GetExit() - os.Exit(int(payload.Code)) + os.Exit(int(*payload.Code)) case *Msg_SourceCodeFetch: payload := msg.GetSourceCodeFetch() - return HandleSourceCodeFetch(payload.ModuleSpecifier, payload.ContainingFile) + return HandleSourceCodeFetch(*payload.ModuleSpecifier, *payload.ContainingFile) case *Msg_SourceCodeCache: payload := msg.GetSourceCodeCache() - return HandleSourceCodeCache(payload.Filename, payload.SourceCode, - payload.OutputCode) + return HandleSourceCodeCache(*payload.Filename, *payload.SourceCode, + *payload.OutputCode) default: panic("[os] Unexpected message " + string(buf)) } @@ -39,7 +39,8 @@ func HandleSourceCodeFetch(moduleSpecifier string, containingFile string) (out [ defer func() { if err != nil { - res.Error = err.Error() + var errStr = err.Error() + res.Error = &errStr } out, err = proto.Marshal(res) check(err) @@ -72,12 +73,13 @@ func HandleSourceCodeFetch(moduleSpecifier string, containingFile string) (out [ return } + var sourceCode = string(sourceCodeBuf) res.Payload = &Msg_SourceCodeFetchRes{ SourceCodeFetchRes: &SourceCodeFetchResMsg{ - ModuleName: moduleName, - Filename: filename, - SourceCode: string(sourceCodeBuf), - OutputCode: outputCode, + ModuleName: &moduleName, + Filename: &filename, + SourceCode: &sourceCode, + OutputCode: &outputCode, }, } return @@ -91,7 +93,8 @@ func HandleSourceCodeCache(filename string, sourceCode string, err := ioutil.WriteFile(fn, outputCodeBuf, 0600) res := &Msg{} if err != nil { - res.Error = err.Error() + var errStr = err.Error() + res.Error = &errStr } out, err := proto.Marshal(res) check(err) -- cgit v1.2.3