summaryrefslogtreecommitdiff
path: root/os.go
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-05-25 15:30:09 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-05-25 15:30:09 -0400
commit5b858632acb672c1f38145edac9df11fdbcacad6 (patch)
treeb7fedecabd9ffa73776ebc5648e538ad84dad789 /os.go
parentd765300de5b2786e236b4aea8a61e32faf4ba605 (diff)
Use proto3 again.
Diffstat (limited to 'os.go')
-rw-r--r--os.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/os.go b/os.go
index fe4789961..9a677ed6e 100644
--- a/os.go
+++ b/os.go
@@ -18,14 +18,15 @@ 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))
}
@@ -64,8 +65,7 @@ func HandleSourceCodeFetch(moduleSpecifier string, containingFile string) (out [
defer func() {
if err != nil {
- var errStr = err.Error()
- res.Error = &errStr
+ res.Error = err.Error()
}
out, err = proto.Marshal(res)
check(err)
@@ -101,11 +101,11 @@ func HandleSourceCodeFetch(moduleSpecifier string, containingFile string) (out [
var sourceCode = string(sourceCodeBuf)
var command = Msg_SOURCE_CODE_FETCH_RES
res = &Msg{
- Command: &command,
- SourceCodeFetchResModuleName: &moduleName,
- SourceCodeFetchResFilename: &filename,
- SourceCodeFetchResSourceCode: &sourceCode,
- SourceCodeFetchResOutputCode: &outputCode,
+ Command: command,
+ SourceCodeFetchResModuleName: moduleName,
+ SourceCodeFetchResFilename: filename,
+ SourceCodeFetchResSourceCode: sourceCode,
+ SourceCodeFetchResOutputCode: outputCode,
}
return
}
@@ -118,8 +118,7 @@ func HandleSourceCodeCache(filename string, sourceCode string,
err := ioutil.WriteFile(fn, outputCodeBuf, 0600)
res := &Msg{}
if err != nil {
- var errStr = err.Error()
- res.Error = &errStr
+ res.Error = err.Error()
}
out, err := proto.Marshal(res)
check(err)