1) Change default gofmt default settings for
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
2nd set of files.
R=rsc
CC=golang-dev
https://golang.org/cl/179067
diff --git a/src/pkg/expvar/expvar.go b/src/pkg/expvar/expvar.go
index 3a2e74b..b8f9bae 100644
--- a/src/pkg/expvar/expvar.go
+++ b/src/pkg/expvar/expvar.go
@@ -8,89 +8,89 @@
package expvar
import (
- "bytes";
- "fmt";
- "http";
- "log";
- "strconv";
- "sync";
+ "bytes"
+ "fmt"
+ "http"
+ "log"
+ "strconv"
+ "sync"
)
// Var is an abstract type for all exported variables.
type Var interface {
- String() string;
+ String() string
}
// Int is a 64-bit integer variable, and satisfies the Var interface.
type Int struct {
- i int64;
- mu sync.Mutex;
+ i int64
+ mu sync.Mutex
}
-func (v *Int) String() string { return strconv.Itoa64(v.i) }
+func (v *Int) String() string { return strconv.Itoa64(v.i) }
func (v *Int) Add(delta int64) {
- v.mu.Lock();
- defer v.mu.Unlock();
- v.i += delta;
+ v.mu.Lock()
+ defer v.mu.Unlock()
+ v.i += delta
}
// Map is a string-to-Var map variable, and satisfies the Var interface.
type Map struct {
- m map[string]Var;
- mu sync.Mutex;
+ m map[string]Var
+ mu sync.Mutex
}
// KeyValue represents a single entry in a Map.
type KeyValue struct {
- Key string;
- Value Var;
+ Key string
+ Value Var
}
func (v *Map) String() string {
- v.mu.Lock();
- defer v.mu.Unlock();
- b := new(bytes.Buffer);
- fmt.Fprintf(b, "{");
- first := true;
+ v.mu.Lock()
+ defer v.mu.Unlock()
+ b := new(bytes.Buffer)
+ fmt.Fprintf(b, "{")
+ first := true
for key, val := range v.m {
if !first {
fmt.Fprintf(b, ", ")
}
- fmt.Fprintf(b, "\"%s\": %v", key, val.String());
- first = false;
+ fmt.Fprintf(b, "\"%s\": %v", key, val.String())
+ first = false
}
- fmt.Fprintf(b, "}");
- return b.String();
+ fmt.Fprintf(b, "}")
+ return b.String()
}
func (v *Map) Init() *Map {
- v.m = make(map[string]Var);
- return v;
+ v.m = make(map[string]Var)
+ return v
}
func (v *Map) Get(key string) Var {
- v.mu.Lock();
- defer v.mu.Unlock();
+ v.mu.Lock()
+ defer v.mu.Unlock()
if av, ok := v.m[key]; ok {
return av
}
- return nil;
+ return nil
}
func (v *Map) Set(key string, av Var) {
- v.mu.Lock();
- defer v.mu.Unlock();
- v.m[key] = av;
+ v.mu.Lock()
+ defer v.mu.Unlock()
+ v.m[key] = av
}
func (v *Map) Add(key string, delta int64) {
- v.mu.Lock();
- defer v.mu.Unlock();
- av, ok := v.m[key];
+ v.mu.Lock()
+ defer v.mu.Unlock()
+ av, ok := v.m[key]
if !ok {
- av = new(Int);
- v.m[key] = av;
+ av = new(Int)
+ v.m[key] = av
}
// Add to Int; ignore otherwise.
@@ -104,29 +104,29 @@
for k, v := range v.m {
c <- KeyValue{k, v}
}
- close(c);
+ close(c)
}
func (v *Map) Iter() <-chan KeyValue {
- c := make(chan KeyValue);
- go v.iterate(c);
- return c;
+ c := make(chan KeyValue)
+ go v.iterate(c)
+ return c
}
// String is a string variable, and satisfies the Var interface.
type String struct {
- s string;
+ s string
}
-func (v *String) String() string { return strconv.Quote(v.s) }
+func (v *String) String() string { return strconv.Quote(v.s) }
-func (v *String) Set(value string) { v.s = value }
+func (v *String) Set(value string) { v.s = value }
// IntFunc wraps a func() int64 to create a value that satisfies the Var interface.
// The function will be called each time the Var is evaluated.
type IntFunc func() int64
-func (v IntFunc) String() string { return strconv.Itoa64(v()) }
+func (v IntFunc) String() string { return strconv.Itoa64(v()) }
// All published variables.
@@ -137,12 +137,12 @@
// package's init function when it creates its Vars. If the name is already
// registered then this will log.Crash.
func Publish(name string, v Var) {
- mutex.Lock();
- defer mutex.Unlock();
+ mutex.Lock()
+ defer mutex.Unlock()
if _, existing := vars[name]; existing {
log.Crash("Reuse of exported var name:", name)
}
- vars[name] = v;
+ vars[name] = v
}
// Get retrieves a named exported variable.
@@ -150,35 +150,35 @@
if v, ok := vars[name]; ok {
return v
}
- return nil;
+ return nil
}
// RemoveAll removes all exported variables.
// This is for tests; don't call this on a real server.
func RemoveAll() {
- mutex.Lock();
- defer mutex.Unlock();
- vars = make(map[string]Var);
+ mutex.Lock()
+ defer mutex.Unlock()
+ vars = make(map[string]Var)
}
// Convenience functions for creating new exported variables.
func NewInt(name string) *Int {
- v := new(Int);
- Publish(name, v);
- return v;
+ v := new(Int)
+ Publish(name, v)
+ return v
}
func NewMap(name string) *Map {
- v := new(Map).Init();
- Publish(name, v);
- return v;
+ v := new(Map).Init()
+ Publish(name, v)
+ return v
}
func NewString(name string) *String {
- v := new(String);
- Publish(name, v);
- return v;
+ v := new(String)
+ Publish(name, v)
+ return v
}
// TODO(rsc): Make sure map access in separate thread is safe.
@@ -186,27 +186,27 @@
for k, v := range vars {
c <- KeyValue{k, v}
}
- close(c);
+ close(c)
}
func Iter() <-chan KeyValue {
- c := make(chan KeyValue);
- go iterate(c);
- return c;
+ c := make(chan KeyValue)
+ go iterate(c)
+ return c
}
func expvarHandler(c *http.Conn, req *http.Request) {
- c.SetHeader("content-type", "application/json; charset=utf-8");
- fmt.Fprintf(c, "{\n");
- first := true;
+ c.SetHeader("content-type", "application/json; charset=utf-8")
+ fmt.Fprintf(c, "{\n")
+ first := true
for name, value := range vars {
if !first {
fmt.Fprintf(c, ",\n")
}
- first = false;
- fmt.Fprintf(c, " %q: %s", name, value);
+ first = false
+ fmt.Fprintf(c, " %q: %s", name, value)
}
- fmt.Fprintf(c, "\n}\n");
+ fmt.Fprintf(c, "\n}\n")
}
-func init() { http.Handle("/debug/vars", http.HandlerFunc(expvarHandler)) }
+func init() { http.Handle("/debug/vars", http.HandlerFunc(expvarHandler)) }