Skip to content

Commit d0a69e9

Browse files
committed
gocode: Replace usages of fmt.Print* with log.Print*
We should never write to stdout, only stderr. Otherwise programs which use stdout/stdin communication will break. Ran the following from the gocode directory: codemod --extensions go fmt.P log.P goimports -w * Fixes sourcegraph#313
1 parent 7df19dc commit d0a69e9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

langserver/internal/gocode/decl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ func infer_type(v ast.Expr, scope *scope, index int) (ast.Expr, *scope, bool) {
937937
return t, scope, true
938938
default:
939939
_ = reflect.TypeOf(v)
940-
//fmt.Println(ty)
940+
//log.Println(ty)
941941
}
942942
return nil, nil, false
943943
}

langserver/internal/gocode/utils.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"go/build"
77
"io/ioutil"
8+
"log"
89
"os"
910
"path/filepath"
1011
"runtime"
@@ -184,18 +185,18 @@ var g_backtrace_mutex sync.Mutex
184185
func print_backtrace(err interface{}) {
185186
g_backtrace_mutex.Lock()
186187
defer g_backtrace_mutex.Unlock()
187-
fmt.Printf("panic: %v\n", err)
188+
log.Printf("panic: %v\n", err)
188189
i := 2
189190
for {
190191
pc, file, line, ok := runtime.Caller(i)
191192
if !ok {
192193
break
193194
}
194195
f := runtime.FuncForPC(pc)
195-
fmt.Printf("%d(%s): %s:%d\n", i-1, f.Name(), file, line)
196+
log.Printf("%d(%s): %s:%d\n", i-1, f.Name(), file, line)
196197
i++
197198
}
198-
fmt.Println("")
199+
log.Println("")
199200
}
200201

201202
//-------------------------------------------------------------------------

0 commit comments

Comments
 (0)