summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-04-26 09:55:32 +0200
committerOndřej Surý <ondrej@sury.org>2011-04-26 09:55:32 +0200
commit7b15ed9ef455b6b66c6b376898a88aef5d6a9970 (patch)
tree3ef530baa80cdf29436ba981f5783be6b4d2202b /misc
parent50104cc32a498f7517a51c8dc93106c51c7a54b4 (diff)
downloadgolang-7b15ed9ef455b6b66c6b376898a88aef5d6a9970.tar.gz
Imported Upstream version 2011.04.13upstream/2011.04.13
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/bbedit/Go.plist3
-rw-r--r--misc/cgo/stdio/Makefile3
-rw-r--r--misc/cgo/stdio/hello.go20
-rw-r--r--misc/cgo/test/Makefile23
-rw-r--r--misc/cgo/test/align.go (renamed from misc/cgo/stdio/align.go)18
-rw-r--r--misc/cgo/test/basic.go (renamed from misc/cgo/stdio/test.go)36
-rw-r--r--misc/cgo/test/callback.go136
-rw-r--r--misc/cgo/test/callback_c.c12
-rw-r--r--misc/cgo/test/cgo_test.go5
-rw-r--r--misc/cgo/test/issue1222.go (renamed from misc/cgo/stdio/test1.go)2
-rw-r--r--misc/cgo/test/issue1328.go30
-rw-r--r--misc/cgo/test/issue1560.go46
-rw-r--r--misc/cgo/test/runtime.c21
-rw-r--r--misc/dashboard/README34
-rw-r--r--misc/dashboard/buildcontrol.py278
-rw-r--r--misc/dashboard/buildcron.sh58
-rw-r--r--misc/dashboard/builder.sh95
-rw-r--r--misc/dashboard/builder/doc.go6
-rw-r--r--misc/dashboard/builder/exec.go2
-rw-r--r--misc/dashboard/builder/main.go2
-rw-r--r--misc/dashboard/godashboard/gobuild.py4
-rw-r--r--misc/dashboard/godashboard/package.py21
-rw-r--r--misc/emacs/go-mode-load.el19
-rw-r--r--misc/emacs/go-mode.el58
-rw-r--r--misc/goplay/goplay.go2
-rw-r--r--misc/kate/go.xml18
-rwxr-xr-xmisc/notepadplus/README8
-rwxr-xr-xmisc/notepadplus/go.xml66
-rwxr-xr-xmisc/notepadplus/userDefineLang.xml36
-rw-r--r--misc/swig/callback/Makefile17
-rw-r--r--misc/swig/callback/callback.h24
-rw-r--r--misc/swig/callback/callback.swigcxx18
-rwxr-xr-xmisc/swig/callback/runbin0 -> 1179384 bytes
-rw-r--r--misc/swig/callback/run.go39
-rw-r--r--misc/swig/stdio/Makefile17
-rw-r--r--misc/swig/stdio/file.swig11
-rwxr-xr-xmisc/swig/stdio/hellobin0 -> 231270 bytes
-rw-r--r--misc/swig/stdio/hello.go11
-rw-r--r--misc/vim/ftplugin/go/fmt.vim30
-rw-r--r--misc/vim/indent/go.vim30
-rw-r--r--misc/vim/readme.txt13
-rw-r--r--misc/vim/syntax/go.vim4
42 files changed, 709 insertions, 567 deletions
diff --git a/misc/bbedit/Go.plist b/misc/bbedit/Go.plist
index 9dc3bf6f1..45535350a 100755
--- a/misc/bbedit/Go.plist
+++ b/misc/bbedit/Go.plist
@@ -14,7 +14,6 @@
case,
chan,
close,
- closed,
complex,
complex128,
complex64,
@@ -95,7 +94,7 @@
"Open Strings 1" = "`";
"Open Strings 2" = "\"";
"Prefix for Functions" = "func";
- "Prefix for Procedures" = func;
+ "Prefix for Procedures" = "func";
"Terminator for Prototypes 1" = ";";
"Terminator for Prototypes 2" = "";
};
diff --git a/misc/cgo/stdio/Makefile b/misc/cgo/stdio/Makefile
index fc925e607..3f7a4c01c 100644
--- a/misc/cgo/stdio/Makefile
+++ b/misc/cgo/stdio/Makefile
@@ -6,10 +6,7 @@ include ../../../src/Make.inc
TARG=stdio
CGOFILES=\
- align.go\
file.go\
- test.go\
- test1.go\
CLEANFILES+=hello fib chain run.out
diff --git a/misc/cgo/stdio/hello.go b/misc/cgo/stdio/hello.go
index 9cb6e6884..58fc6d574 100644
--- a/misc/cgo/stdio/hello.go
+++ b/misc/cgo/stdio/hello.go
@@ -4,26 +4,8 @@
package main
-import (
- "os"
- "stdio"
-)
+import "stdio"
func main() {
stdio.Stdout.WriteString(stdio.Greeting + "\n")
-
- l := stdio.Atol("123")
- if l != 123 {
- println("Atol 123: ", l)
- panic("bad atol")
- }
-
- n, err := stdio.Strtol("asdf", 123)
- if n != 0 || err != os.EINVAL {
- println("Strtol: ", n, err)
- panic("bad atoi2")
- }
-
- stdio.TestAlign()
- stdio.TestEnum()
}
diff --git a/misc/cgo/test/Makefile b/misc/cgo/test/Makefile
new file mode 100644
index 000000000..893540d97
--- /dev/null
+++ b/misc/cgo/test/Makefile
@@ -0,0 +1,23 @@
+# Copyright 2011 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+include ../../../src/Make.inc
+
+TARG=runtime/cgotest
+
+CGOFILES=\
+ align.go\
+ basic.go\
+ callback.go\
+ issue1222.go\
+ issue1328.go\
+ issue1560.go\
+
+CGO_OFILES=\
+ callback_c.o\
+
+OFILES=\
+ runtime.$O\
+
+include ../../../src/Make.pkg
diff --git a/misc/cgo/stdio/align.go b/misc/cgo/test/align.go
index 6cdfd902f..2d2979595 100644
--- a/misc/cgo/stdio/align.go
+++ b/misc/cgo/test/align.go
@@ -1,4 +1,4 @@
-package stdio
+package cgotest
/*
#include <stdio.h>
@@ -55,24 +55,18 @@ void cTest(SDL_KeyboardEvent *event) {
import "C"
import (
- "fmt"
- "syscall"
+ "testing"
)
-func TestAlign() {
- if syscall.ARCH == "amd64" {
- // alignment is known to be broken on amd64.
- // http://code.google.com/p/go/issues/detail?id=609
- return
- }
+func TestAlign(t *testing.T) {
var evt C.SDL_KeyboardEvent
C.makeEvent(&evt)
if C.same(&evt, evt.typ, evt.which, evt.state, evt.keysym.scancode, evt.keysym.sym, evt.keysym.mod, evt.keysym.unicode) == 0 {
- fmt.Println("*** bad alignment")
+ t.Error("*** bad alignment")
C.cTest(&evt)
- fmt.Printf("Go: %#x %#x %#x %#x %#x %#x %#x\n",
+ t.Errorf("Go: %#x %#x %#x %#x %#x %#x %#x\n",
evt.typ, evt.which, evt.state, evt.keysym.scancode,
evt.keysym.sym, evt.keysym.mod, evt.keysym.unicode)
- fmt.Println(evt)
+ t.Error(evt)
}
}
diff --git a/misc/cgo/stdio/test.go b/misc/cgo/test/basic.go
index 8f21603ca..a94074c52 100644
--- a/misc/cgo/stdio/test.go
+++ b/misc/cgo/test/basic.go
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// This file contains test cases for cgo.
+// Basic test cases for cgo.
-package stdio
+package cgotest
/*
#include <stdio.h>
@@ -52,6 +52,7 @@ struct ibv_context {
import "C"
import (
"os"
+ "testing"
"unsafe"
)
@@ -89,38 +90,35 @@ func Atol(s string) int {
return int(n)
}
-func TestConst() {
+func TestConst(t *testing.T) {
C.myConstFunc(nil, 0, nil)
}
-func TestEnum() {
+func TestEnum(t *testing.T) {
if C.Enum1 != 1 || C.Enum2 != 2 {
- println("bad enum", C.Enum1, C.Enum2)
+ t.Error("bad enum", C.Enum1, C.Enum2)
}
}
-func TestAtol() {
+func TestAtol(t *testing.T) {
l := Atol("123")
if l != 123 {
- println("Atol 123: ", l)
- panic("bad atol")
+ t.Error("Atol 123: ", l)
}
}
-func TestErrno() {
+func TestErrno(t *testing.T) {
n, err := Strtol("asdf", 123)
if n != 0 || err != os.EINVAL {
- println("Strtol: ", n, err)
- panic("bad strtol")
+ t.Error("Strtol: ", n, err)
}
}
-func TestMultipleAssign() {
- p := C.CString("123")
+func TestMultipleAssign(t *testing.T) {
+ p := C.CString("234")
n, m := C.strtol(p, nil, 345), C.strtol(p, nil, 10)
if n != 0 || m != 234 {
- println("Strtol x2: ", n, m)
- panic("bad strtol x2")
+ t.Fatal("Strtol x2: ", n, m)
}
C.free(unsafe.Pointer(p))
}
@@ -134,11 +132,3 @@ var (
type Context struct {
ctx *C.struct_ibv_context
}
-
-func Test() {
- TestAlign()
- TestAtol()
- TestEnum()
- TestErrno()
- TestConst()
-}
diff --git a/misc/cgo/test/callback.go b/misc/cgo/test/callback.go
new file mode 100644
index 000000000..450a7cbf2
--- /dev/null
+++ b/misc/cgo/test/callback.go
@@ -0,0 +1,136 @@
+package cgotest
+
+/*
+void callback(void *f);
+void callGoFoo(void) {
+ extern void goFoo(void);
+ goFoo();
+}
+*/
+import "C"
+
+import (
+ "runtime"
+ "testing"
+ "unsafe"
+)
+
+// nestedCall calls into C, back into Go, and finally to f.
+func nestedCall(f func()) {
+ // NOTE: Depends on representation of f.
+ // callback(x) calls goCallback(x)
+ C.callback(*(*unsafe.Pointer)(unsafe.Pointer(&f)))
+}
+
+//export goCallback
+func goCallback(p unsafe.Pointer) {
+ (*(*func())(unsafe.Pointer(&p)))()
+}
+
+func TestCallback(t *testing.T) {
+ var x = false
+ nestedCall(func() { x = true })
+ if !x {
+ t.Fatal("nestedCall did not call func")
+ }
+}
+
+func TestCallbackGC(t *testing.T) {
+ nestedCall(runtime.GC)
+}
+
+func lockedOSThread() bool // in runtime.c
+
+func TestCallbackPanic(t *testing.T) {
+ // Make sure panic during callback unwinds properly.
+ if lockedOSThread() {
+ t.Fatal("locked OS thread on entry to TestCallbackPanic")
+ }
+ defer func() {
+ s := recover()
+ if s == nil {
+ t.Fatal("did not panic")
+ }
+ if s.(string) != "callback panic" {
+ t.Fatal("wrong panic:", s)
+ }
+ if lockedOSThread() {
+ t.Fatal("locked OS thread on exit from TestCallbackPanic")
+ }
+ }()
+ nestedCall(func() { panic("callback panic") })
+ panic("nestedCall returned")
+}
+
+func TestCallbackPanicLoop(t *testing.T) {
+ // Make sure we don't blow out m->g0 stack.
+ for i := 0; i < 100000; i++ {
+ TestCallbackPanic(t)
+ }
+}
+
+func TestCallbackPanicLocked(t *testing.T) {
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ if !lockedOSThread() {
+ t.Fatal("runtime.LockOSThread didn't")
+ }
+ defer func() {
+ s := recover()
+ if s == nil {
+ t.Fatal("did not panic")
+ }
+ if s.(string) != "callback panic" {
+ t.Fatal("wrong panic:", s)
+ }
+ if !lockedOSThread() {
+ t.Fatal("lost lock on OS thread after panic")
+ }
+ }()
+ nestedCall(func() { panic("callback panic") })
+ panic("nestedCall returned")
+}
+
+// Callback with zero arguments used to make the stack misaligned,
+// which broke the garbage collector and other things.
+func TestZeroArgCallback(t *testing.T) {
+ defer func() {
+ s := recover()
+ if s != nil {
+ t.Fatal("panic during callback:", s)
+ }
+ }()
+ C.callGoFoo()
+}
+
+//export goFoo
+func goFoo() {
+ x := 1
+ for i := 0; i < 10000; i++ {
+ // variadic call mallocs + writes to
+ variadic(x, x, x)
+ if x != 1 {
+ panic("bad x")
+ }
+ }
+}
+
+func variadic(x ...interface{}) {}
+
+func TestBlocking(t *testing.T) {
+ c := make(chan int)
+ go func() {
+ for i := 0; i < 10; i++ {
+ c <- <-c
+ }
+ }()
+ nestedCall(func() {
+ for i := 0; i < 10; i++ {
+ c <- i
+ if j := <-c; j != i {
+ t.Errorf("out of sync %d != %d", j, i)
+ }
+ }
+ })
+}
diff --git a/misc/cgo/test/callback_c.c b/misc/cgo/test/callback_c.c
new file mode 100644
index 000000000..5983a5e11
--- /dev/null
+++ b/misc/cgo/test/callback_c.c
@@ -0,0 +1,12 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include <sys/types.h>
+#include "_cgo_export.h"
+
+void
+callback(void *f)
+{
+ goCallback(f);
+}
diff --git a/misc/cgo/test/cgo_test.go b/misc/cgo/test/cgo_test.go
new file mode 100644
index 000000000..967dc0e92
--- /dev/null
+++ b/misc/cgo/test/cgo_test.go
@@ -0,0 +1,5 @@
+package cgotest
+
+// dummy file so gotest thinks there are tests.
+// the actual tests are in the main go files, next
+// to the code they test.
diff --git a/misc/cgo/stdio/test1.go b/misc/cgo/test/issue1222.go
index dce2ef83c..c396a0c41 100644
--- a/misc/cgo/stdio/test1.go
+++ b/misc/cgo/test/issue1222.go
@@ -4,7 +4,7 @@
// This file contains test cases for cgo.
-package stdio
+package cgotest
/*
// issue 1222
diff --git a/misc/cgo/test/issue1328.go b/misc/cgo/test/issue1328.go
new file mode 100644
index 000000000..f29d7057e
--- /dev/null
+++ b/misc/cgo/test/issue1328.go
@@ -0,0 +1,30 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cgotest
+
+import "testing"
+
+// extern void BackIntoGo(void);
+// void IntoC() { BackIntoGo(); }
+import "C"
+
+//export BackIntoGo
+func BackIntoGo() {
+ x := 1
+
+ for i := 0; i < 10000; i++ {
+ xvariadic(x)
+ if x != 1 {
+ panic("x is not 1?")
+ }
+ }
+}
+
+func xvariadic(x ...interface{}) {
+}
+
+func Test1328(t *testing.T) {
+ C.IntoC()
+}
diff --git a/misc/cgo/test/issue1560.go b/misc/cgo/test/issue1560.go
new file mode 100644
index 000000000..75d31c035
--- /dev/null
+++ b/misc/cgo/test/issue1560.go
@@ -0,0 +1,46 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cgotest
+
+/*
+#include <unistd.h>
+
+extern void BackgroundSleep(int);
+void twoSleep(int n) {
+ BackgroundSleep(n);
+ sleep(n);
+}
+*/
+import "C"
+
+import (
+ "testing"
+ "time"
+)
+
+var sleepDone = make(chan bool)
+
+func parallelSleep(n int) {
+ C.twoSleep(C.int(n))
+ <-sleepDone
+}
+
+//export BackgroundSleep
+func BackgroundSleep(n int) {
+ go func() {
+ C.sleep(C.uint(n))
+ sleepDone <- true
+ }()
+}
+
+func TestParallelSleep(t *testing.T) {
+ dt := -time.Nanoseconds()
+ parallelSleep(1)
+ dt += time.Nanoseconds()
+ // bug used to run sleeps in serial, producing a 2-second delay.
+ if dt >= 1.3e9 {
+ t.Fatalf("parallel 1-second sleeps slept for %f seconds", float64(dt)/1e9)
+ }
+}
diff --git a/misc/cgo/test/runtime.c b/misc/cgo/test/runtime.c
new file mode 100644
index 000000000..e087c7622
--- /dev/null
+++ b/misc/cgo/test/runtime.c
@@ -0,0 +1,21 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Expose some runtime functions for testing.
+
+typedef char bool;
+
+bool runtime·lockedOSThread(void);
+
+static void
+FLUSH(void*)
+{
+}
+
+void
+·lockedOSThread(bool b)
+{
+ b = runtime·lockedOSThread();
+ FLUSH(&b);
+}
diff --git a/misc/dashboard/README b/misc/dashboard/README
index 72d5546a4..c00311ef7 100644
--- a/misc/dashboard/README
+++ b/misc/dashboard/README
@@ -4,28 +4,12 @@
The files in this directory constitute the continuous builder:
-godashboard/: An AppEngine that acts as a server
-builder.sh, buildcontrol.sh: used by the build slaves
-buildcron.sh: a build loop that can be run regularly via cron
+godashboard/: an AppEngine server
+builder/: gobuilder, a Go continuous build client
If you wish to run a Go builder, please email golang-dev@googlegroups.com
-
-To set up a Go builder automatically, run buildcron.sh
-(you might want to read it first to see what it does).
-
-To set up a Go builder by hand:
-
-* (Optional) create a new user 'gobuild'
-* Edit ~gobuild/.bash_profile and add the following:
-
-export GOROOT=/gobuild/go
-export GOARCH=XXX
-export GOOS=XXX
-export GOBIN=/gobuild/bin
-export PATH=$PATH:/gobuild/bin
-export BUILDER=$GOOS-$GOARCH
-export BUILDHOST=godashboard.appspot.com
+To run a builder:
* Write the key ~gobuild/.gobuildkey
You need to get it from someone who knows the key.
@@ -38,13 +22,5 @@ export BUILDHOST=godashboard.appspot.com
(This is for uploading tarballs to the project downloads section,
and is an optional step.)
-* sudo apt-get install bison gcc libc6-dev ed make
-* cd ~gobuild
-* mkdir bin
-* hg clone https://go.googlecode.com/hg/ $GOROOT
-* copy builder.sh and buildcontrol.py to ~gobuild
-* chmod a+x ./builder.sh ./buildcontrol.py
-* cd go
-* ../buildcontrol.py next $BUILDER (just to check that things are ok)
-* cd ..
-* ./builder.sh (You probably want to run this in a screen long term.)
+* Build and run gobuilder (see its documentation for command-line options).
+
diff --git a/misc/dashboard/buildcontrol.py b/misc/dashboard/buildcontrol.py
deleted file mode 100644
index ec503e7ff..000000000
--- a/misc/dashboard/buildcontrol.py
+++ /dev/null
@@ -1,278 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# This is a utility script for implementing a Go build slave.
-
-import binascii
-import httplib
-import os
-import struct
-import subprocess
-import sys
-import time
-
-buildhost = ''
-buildport = -1
-buildkey = ''
-
-upload_project = "go"
-
-def main(args):
- global buildport, buildhost, buildkey
-
- if len(args) < 2:
- return usage(args[0])
-
- if 'BUILDHOST' not in os.environ:
- print >>sys.stderr, "Please set $BUILDHOST"
- return
- buildhost = os.environ['BUILDHOST']
-
- if 'BUILDPORT' not in os.environ:
- buildport = 80
- else:
- buildport = int(os.environ['BUILDPORT'])
-
- try:
- buildkeyfile = file('%s/.gobuildkey-%s' % (os.environ['HOME'], os.environ['BUILDER']), 'r')
- buildkey = buildkeyfile.readline().strip()
- except IOError:
- try:
- buildkeyfile = file('%s/.gobuildkey' % os.environ['HOME'], 'r')
- buildkey = buildkeyfile.readline().strip()
- except IOError:
- print >>sys.stderr, "Need key in ~/.gobuildkey-%s or ~/.gobuildkey" % os.environ['BUILDER']
- return
-
- # get upload credentials
- try:
- username = buildkeyfile.readline().strip()
- password = buildkeyfile.readline().strip()
- except:
- username, password = None, None
-
- if args[1] == 'init':
- return doInit(args)
- elif args[1] == 'hwget':
- return doHWGet(args)
- elif args[1] == 'hwset':
- return doHWSet(args)
- elif args[1] == 'next':
- return doNext(args)
- elif args[1] == 'record':
- return doRecord(args)
- elif args[1] == 'benchmarks':
- return doBenchmarks(args)
- elif args[1] == 'upload':
- return doUpload(args, username, password)
- else:
- return usage(args[0])
-
-def usage(name):
- sys.stderr.write('''Usage: %s <command>
-
-Commands:
- init <rev>: init the build bot with the given commit as the first in history
- hwget <builder>: get the most recent revision built by the given builder
- hwset <builder> <rev>: get the most recent revision built by the given builder
- next <builder>: get the next revision number to by built by the given builder
- record <builder> <rev> <ok|log file>: record a build result
- benchmarks <builder> <rev> <log file>: record benchmark numbers
- upload <builder> <summary> <tar file>: upload tarball to googlecode
-''' % name)
- return 1
-
-def doInit(args):
- if len(args) != 3:
- return usage(args[0])
- c = getCommit(args[2])
- if c is None:
- fatal('Cannot get commit %s' % args[2])
-
- return command('init', {'node': c.node, 'date': c.date, 'user': c.user, 'desc': c.desc})
-
-def doHWGet(args, retries = 0):
- if len(args) != 3:
- return usage(args[0])
- conn = httplib.HTTPConnection(buildhost, buildport, True)
- conn.request('GET', '/hw-get?builder=%s' % args[2]);
- reply = conn.getresponse()
- if reply.status == 200:
- print reply.read()
- elif reply.status == 500 and retries < 3:
- time.sleep(3)
- return doHWGet(args, retries = retries + 1)
- else:
- raise Failed('get-hw returned %d' % reply.status)
- return 0
-
-def doHWSet(args):
- if len(args) != 4:
- return usage(args[0])
- c = getCommit(args[3])
- if c is None:
- fatal('Cannot get commit %s' % args[3])
-
- return command('hw-set', {'builder': args[2], 'hw': c.node})
-
-def doNext(args):
- if len(args) != 3:
- return usage(args[0])
- conn = httplib.HTTPConnection(buildhost, buildport, True)
- conn.request('GET', '/hw-get?builder=%s' % args[2]);
- reply = conn.getresponse()
- if reply.status == 200:
- rev = reply.read()
- else:
- raise Failed('get-hw returned %d' % reply.status)
-
- c = getCommit(rev)
- next = getCommit(str(c.num + 1))
- if next is not None and next.parent == c.node:
- print c.num + 1
- else:
- print "<none>"
- return 0
-
-def doRecord(args):
- if len(args) != 5:
- return usage(args[0])
- builder = args[2]
- rev = args[3]
- c = getCommit(rev)
- if c is None:
- print >>sys.stderr, "Bad revision:", rev
- return 1
- logfile = args[4]
- log = ''
- if logfile != 'ok':
- log = file(logfile, 'r').read()
- return command('build', {'node': c.node, 'parent': c.parent, 'date': c.date, 'user': c.user, 'desc': c.desc, 'log': log, 'builder': builder})
-
-def doBenchmarks(args):
- if len(args) != 5:
- return usage(args[0])
- builder = args[2]
- rev = args[3]
- c = getCommit(rev)
- if c is None:
- print >>sys.stderr, "Bad revision:", rev
- return 1
-
- benchmarks = {}
- for line in file(args[4], 'r').readlines():
- if 'Benchmark' in line and 'ns/op' in line:
- parts = line.split()
- if parts[3] == 'ns/op':
- benchmarks[parts[0]] = (parts[1], parts[2])
-
- e = []
- for (name, (a, b)) in benchmarks.items():
- e.append(struct.pack('>H', len(name)))
- e.append(name)
- e.append(struct.pack('>H', len(a)))
- e.append(a)
- e.append(struct.pack('>H', len(b)))
- e.append(b)
- return command('benchmarks', {'node': c.node, 'builder': builder, 'benchmarkdata': binascii.b2a_base64(''.join(e))})
-
-def doUpload(args, username, password):
- # fail gracefully if no username or password set
- if not username or not password:
- return
-
- if len(args) != 5:
- return usage(args[0])
- builder = args[2]
- summary = args[3]
- filename = args[4]
-
- from googlecode_upload import upload
- code, msg, url = upload(
- filename, # filename
- upload_project, # 'go'
- username,
- password,
- summary,
- builder.split('-'), # labels
- )
- if code != 201:
- raise Failed('Upload returned code %s msg "%s".' % (code, msg))
-
-def encodeMultipartFormdata(fields, files):
- """fields is a sequence of (name, value) elements for regular form fields.
- files is a sequence of (name, filename, value) elements for data to be uploaded as files"""
- BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
- CRLF = '\r\n'
- L = []
- for (key, value) in fields.items():
- L.append('--' + BOUNDARY)
- L.append('Content-Disposition: form-data; name="%s"' % key)
- L.append('')
- L.append(value)
- for (key, filename, value) in files:
- L.append('--' + BOUNDARY)
- L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, filename))
- L.append('Content-Type: %s' % get_content_type(filename))
- L.append('')
- L.append(value)
- L.append('--' + BOUNDARY + '--')
- L.append('')
- body = CRLF.join(L)
- content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
- return content_type, body
-
-def unescapeXML(s):
- return s.replace('&lt;', '<').replace('&gt;', '>').replace('&amp;', '&')
-
-class Commit:
- pass
-
-def getCommit(rev):
- output, stderr = subprocess.Popen(['hg', 'log', '-r', rev, '-l', '1', '--template', '{rev}>{node|escape}>{author|escape}>{date}>{desc}'], stdout = subprocess.PIPE, stderr = subprocess.PIPE, close_fds = True).communicate()
- if len(stderr) > 0:
- return None
- [n, node, user, date, desc] = output.split('>', 4)
-
- c = Commit()
- c.num = int(n)
- c.node = unescapeXML(node)
- c.user = unescapeXML(user)
- c.date = unescapeXML(date)
- c.desc = desc
- c.parent = ''
-
- if c.num > 0:
- output, _ = subprocess.Popen(['hg', 'log', '-r', str(c.num - 1), '-l', '1', '--template', '{node}'], stdout = subprocess.PIPE, close_fds = True).communicate()
- c.parent = output
-
- return c
-
-class Failed(Exception):
- def __init__(self, msg):
- self.msg = msg
- def __str__(self):
- return self.msg
-
-def command(cmd, args, retries = 0):
- args['key'] = buildkey
- contentType, body = encodeMultipartFormdata(args, [])
- print body
- conn = httplib.HTTPConnection(buildhost, buildport, True)
- conn.request('POST', '/' + cmd, body, {'Content-Type': contentType})
- reply = conn.getresponse()
- if reply.status != 200:
- print "Command failed. Output:"
- print reply.read()
- if reply.status == 500 and retries < 3:
- print "Was a 500. Waiting two seconds and trying again."
- time.sleep(2)
- return command(cmd, args, retries = retries + 1)
- if reply.status != 200:
- raise Failed('Command "%s" returned %d' % (cmd, reply.status))
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/misc/dashboard/buildcron.sh b/misc/dashboard/buildcron.sh
deleted file mode 100644
index 7aa70ce57..000000000
--- a/misc/dashboard/buildcron.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2010 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# This script can be run to create a new builder and then
-# to keep it running via cron. First, run it by hand until it
-# starts up without errors and can run the loop. Then, once
-# you're confident that it works, add this to your crontab:
-#
-# */5 * * * * cd $HOME; path/to/buildcron.sh darwin 386 >/dev/null 2>/dev/null
-
-if [ $# != 2 ]; then
- echo 'usage: buildcron.sh goos goarch' 1>&2
- exit 2
-fi
-
-export GOOS=$1
-export GOARCH=$2
-
-# Check if we are already running.
-# First command must not be pipeline, to avoid seeing extra processes in ps.
-all=$(ps axwwu)
-pid=$(echo "$all" | grep "buildcron.sh $1 $2" | grep -v "sh -c" | grep -v $$ | awk '{print $2}')
-if [ "$pid" != "" ]; then
- #echo already running buildcron.sh $1 $2
- #echo "$all" | grep "buildcron.sh $1 $2" | grep -v "sh -c" | grep -v $$
- exit 0
-fi
-
-export BUILDHOST=godashboard.appspot.com
-export BUILDER=${GOOS}-${GOARCH}
-export GOROOT=$HOME/go-$BUILDER/go
-export GOBIN=$HOME/go-$BUILDER/bin
-
-if [ ! -f ~/.gobuildkey-$BUILDER ]; then
- echo "need gobuildkey for $BUILDER in ~/.gobuildkey-$BUILDER" 1>&2
- exit 2
-fi
-
-if [ ! -d $GOROOT ]; then
- mkdir -p $GOROOT
- hg clone https://go.googlecode.com/hg/ $GOROOT
-else
- cd $GOROOT
- hg pull -u || exit 1
-fi
-mkdir -p $GOROOT/bin
-
-cd $GOROOT/..
-cp go/misc/dashboard/{builder.sh,buildcontrol.py,googlecode_upload.py} .
-chmod a+x builder.sh buildcontrol.py
-cd go
-../buildcontrol.py next $BUILDER
-cd ..
-./builder.sh
-
-
diff --git a/misc/dashboard/builder.sh b/misc/dashboard/builder.sh
deleted file mode 100644
index 4a8d117bf..000000000
--- a/misc/dashboard/builder.sh
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-fatal() {
- echo $0: $1 1>&2
- exit 1
-}
-
-if [ ! -d go ] ; then
- fatal "Please run in directory that contains a checked out repo in 'go'"
-fi
-
-if [ ! -f buildcontrol.py ] ; then
- fatal 'Please include buildcontrol.py in this directory'
-fi
-
-if [ "x$BUILDER" == "x" ] ; then
- fatal 'Please set $BUILDER to the name of this builder'
-fi
-
-if [ "x$BUILDHOST" == "x" ] ; then
- fatal 'Please set $BUILDHOST to the hostname of the gobuild server'
-fi
-
-if [ "x$GOARCH" == "x" -o "x$GOOS" == "x" ] ; then
- fatal 'Please set $GOARCH and $GOOS'
-fi
-
-export PATH=$PATH:`pwd`/candidate/bin
-export GOBIN=`pwd`/candidate/bin
-export GOROOT_FINAL=/usr/local/go
-
-while true ; do (
- cd go || fatal "Cannot cd into 'go'"
- hg pull -u || fatal "hg sync failed"
- rev=`python ../buildcontrol.py next $BUILDER`
- if [ $? -ne 0 ] ; then
- fatal "Cannot get next revision"
- fi
- cd .. || fatal "Cannot cd up"
- if [ "x$rev" == "x<none>" ] ; then
- sleep 10
- continue
- fi
-
- echo "Cloning for revision $rev"
- rm -Rf candidate
- hg clone -r $rev go candidate || fatal "hg clone failed"
- export GOROOT=`pwd`/candidate
- mkdir -p candidate/bin || fatal "Cannot create candidate/bin"
- cd candidate/src || fatal "Cannot cd into candidate/src"
- echo "Building revision $rev"
- ALL=all.bash
- if [ -f all-$GOOS.bash ]; then
- ALL=all-$GOOS.bash
- elif [ -f all-$GOARCH.bash ]; then
- ALL=all-$GOARCH.bash
- fi
- ./$ALL > ../log 2>&1
- if [ $? -ne 0 ] ; then
- echo "Recording failure for $rev"
- python ../../buildcontrol.py record $BUILDER $rev ../log || fatal "Cannot record result"
- else
- echo "Recording success for $rev"
- python ../../buildcontrol.py record $BUILDER $rev ok || fatal "Cannot record result"
- if [ "$ALL" = "all.bash" ]; then
- echo "Running benchmarks"
- cd pkg || fatal "failed to cd to pkg"
- make bench > ../../benchmarks 2>&1
- python ../../../buildcontrol.py benchmarks $BUILDER $rev ../../benchmarks || fatal "Cannot record benchmarks"
- cd .. || fatal "failed to cd out of pkg"
- fi
- # check if we're at a release (via the hg summary)
- # if so, package the tar.gz and upload to googlecode
- SUMMARY=$(hg log -l 1 | grep summary\: | awk '{print $2}')
- if [[ "x${SUMMARY:0:7}" == "xrelease" ]]; then
- echo "Uploading binary to googlecode"
- TARBALL="go.$SUMMARY.$BUILDER.tar.gz"
- ./clean.bash --nopkg
- # move contents of candidate/ to candidate/go/ for archival
- cd ../.. || fatal "Cannot cd up"
- mv candidate go-candidate || fatal "Cannot rename candidate"
- mkdir candidate || fatal "Cannot mkdir candidate"
- mv go-candidate candidate/go || fatal "Cannot mv directory"
- cd candidate || fatal "Cannot cd candidate"
- # build tarball
- tar czf ../$TARBALL go || fatal "Cannot create tarball"
- ../buildcontrol.py upload $BUILDER $SUMMARY ../$TARBALL || fatal "Cannot upload tarball"
- fi
- fi
- sleep 10
-) done
diff --git a/misc/dashboard/builder/doc.go b/misc/dashboard/builder/doc.go
index a28658a95..7bb7ccbe3 100644
--- a/misc/dashboard/builder/doc.go
+++ b/misc/dashboard/builder/doc.go
@@ -39,7 +39,7 @@ Optional flags:
-release: Build and deliver binary release archive
-rev=N: Build revision N and exit
-
+
-cmd="./all.bash": Build command (specify absolute or relative to go/src)
-v: Verbose logging
@@ -47,8 +47,8 @@ Optional flags:
-external: External package builder mode (will not report Go build
state to dashboard, issue releases, or run benchmarks)
-The key file should be located at $HOME/.gobuilder or, for a builder-specific
-key, $HOME/.gobuilder-$BUILDER (eg, $HOME/.gobuilder-linux-amd64).
+The key file should be located at $HOME/.gobuildkey or, for a builder-specific
+key, $HOME/.gobuildkey-$BUILDER (eg, $HOME/.gobuildkey-linux-amd64).
The build key file is a text file of the format:
diff --git a/misc/dashboard/builder/exec.go b/misc/dashboard/builder/exec.go
index 53ea93ac5..3c6fbdced 100644
--- a/misc/dashboard/builder/exec.go
+++ b/misc/dashboard/builder/exec.go
@@ -49,7 +49,7 @@ func runLog(envv []string, logfile, dir string, argv ...string) (output string,
b := new(bytes.Buffer)
var w io.Writer = b
if logfile != "" {
- f, err := os.Open(logfile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
+ f, err := os.OpenFile(logfile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
return
}
diff --git a/misc/dashboard/builder/main.go b/misc/dashboard/builder/main.go
index fc11d365e..735717e28 100644
--- a/misc/dashboard/builder/main.go
+++ b/misc/dashboard/builder/main.go
@@ -64,7 +64,7 @@ var (
var (
goroot string
- releaseRegexp = regexp.MustCompile(`^release\.[0-9\-.]+`)
+ releaseRegexp = regexp.MustCompile(`^(release|weekly)\.[0-9\-.]+`)
benchRequests vector.Vector
)
diff --git a/misc/dashboard/godashboard/gobuild.py b/misc/dashboard/godashboard/gobuild.py
index 08d70ec64..1eacdb38e 100644
--- a/misc/dashboard/godashboard/gobuild.py
+++ b/misc/dashboard/godashboard/gobuild.py
@@ -7,7 +7,6 @@
from google.appengine.api import mail
from google.appengine.api import memcache
-from google.appengine.runtime import DeadlineExceededError
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
@@ -219,7 +218,7 @@ class SetHighwater(webapp.RequestHandler):
q = Commit.all()
q.order('-__key__')
recent = q.fetch(N+1)
- for c in head:
+ for c in recent:
if c.node == newhw:
found = True
break
@@ -384,7 +383,6 @@ class Benchmarks(webapp.RequestHandler):
self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
self.response.out.write('{"benchmarks": [')
- first = True
sep = "\n\t"
for b in bs:
self.response.out.write('%s"%s"' % (sep, b.name))
diff --git a/misc/dashboard/godashboard/package.py b/misc/dashboard/godashboard/package.py
index 7570d2218..a1bca1908 100644
--- a/misc/dashboard/godashboard/package.py
+++ b/misc/dashboard/godashboard/package.py
@@ -6,7 +6,6 @@
# It must be run by App Engine.
from google.appengine.api import memcache
-from google.appengine.runtime import DeadlineExceededError
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
@@ -14,15 +13,10 @@ from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import users
from google.appengine.api import mail
from google.appengine.api import urlfetch
-import binascii
import datetime
-import hashlib
-import hmac
import logging
import os
import re
-import struct
-import time
import urllib2
import sets
@@ -52,6 +46,8 @@ class Project(db.Model):
re_bitbucket = re.compile(r'^bitbucket\.org/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+$')
re_googlecode = re.compile(r'^[a-z0-9\-]+\.googlecode\.com/(svn|hg)$')
re_github = re.compile(r'^github\.com/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+$')
+re_launchpad = re.compile(r'^launchpad\.net/([a-z0-9A-Z_.\-]+(/[a-z0-9A-Z_.\-]+)?|~[a-z0-9A-Z_.\-]+/(\+junk|[a-z0-9A-Z_.\-]+)/[a-z0-9A-Z_.\-]+)(/[a-z0-9A-Z_.\-/]+)?$')
+
def vc_to_web(path):
if re_bitbucket.match(path):
@@ -65,6 +61,8 @@ def vc_to_web(path):
elif re_googlecode.match(path):
check_url = 'http://'+path
web = 'http://code.google.com/p/' + path[:path.index('.')]
+ elif re_launchpad.match(path):
+ check_url = web = 'https://'+path
else:
return False, False
return web, check_url
@@ -72,7 +70,8 @@ def vc_to_web(path):
re_bitbucket_web = re.compile(r'bitbucket\.org/([a-z0-9A-Z_.\-]+)/([a-z0-9A-Z_.\-]+)')
re_googlecode_web = re.compile(r'code.google.com/p/([a-z0-9\-]+)')
re_github_web = re.compile(r'github\.com/([a-z0-9A-Z_.\-]+)/([a-z0-9A-Z_.\-]+)')
-re_striphttp = re.compile(r'http://(www\.)?')
+re_launchpad_web = re.compile(r'launchpad\.net/([a-z0-9A-Z_.\-]+(/[a-z0-9A-Z_.\-]+)?|~[a-z0-9A-Z_.\-]+/(\+junk|[a-z0-9A-Z_.\-]+)/[a-z0-9A-Z_.\-]+)(/[a-z0-9A-Z_.\-/]+)?')
+re_striphttp = re.compile(r'https?://(www\.)?')
def web_to_vc(url):
url = re_striphttp.sub('', url)
@@ -93,6 +92,9 @@ def web_to_vc(url):
vcs = 'hg'
except: pass
return path + vcs
+ m = re_launchpad_web.match(url)
+ if m:
+ return m.group(0)
return False
MaxPathLength = 100
@@ -136,7 +138,7 @@ class PackagePage(webapp.RequestHandler):
sep = ','
s += '\n]}\n'
json = s
- memcache.set('view-package-json', json, time=CacheTimeoout)
+ memcache.set('view-package-json', json, time=CacheTimeout)
self.response.out.write(json)
def can_get_url(self, url):
@@ -150,7 +152,8 @@ class PackagePage(webapp.RequestHandler):
def is_valid_package_path(self, path):
return (re_bitbucket.match(path) or
re_googlecode.match(path) or
- re_github.match(path))
+ re_github.match(path) or
+ re_launchpad.match(path))
def record_pkg(self, path):
# sanity check string
diff --git a/misc/emacs/go-mode-load.el b/misc/emacs/go-mode-load.el
index c73156317..0ace46dfa 100644
--- a/misc/emacs/go-mode-load.el
+++ b/misc/emacs/go-mode-load.el
@@ -18,10 +18,11 @@
;; (let ((generated-autoload-file buffer-file-name)) (update-file-autoloads "go-mode.el"))
-;;;### (autoloads (go-mode) "go-mode" "go-mode.el" (19168 32439))
+;;;### (autoloads (gofmt-before-save gofmt go-mode) "go-mode" "go-mode.el"
+;;;;;; (19847 61431))
;;; Generated autoloads from go-mode.el
-(autoload (quote go-mode) "go-mode" "\
+(autoload 'go-mode "go-mode" "\
Major mode for editing Go source text.
This provides basic syntax highlighting for keywords, built-ins,
@@ -30,7 +31,19 @@ functions, and some types. It also provides indentation that is
\(fn)" t nil)
-(add-to-list (quote auto-mode-alist) (cons "\\.go$" (function go-mode)))
+(add-to-list 'auto-mode-alist (cons "\\.go$" #'go-mode))
+
+(autoload 'gofmt "go-mode" "\
+Pipe the current buffer through the external tool `gofmt`.
+Replace the current buffer on success; display errors on failure.
+
+\(fn)" t nil)
+
+(autoload 'gofmt-before-save "go-mode" "\
+Add this to .emacs to run gofmt on the current buffer when saving:
+ (add-hook 'before-save-hook #'gofmt-before-save)
+
+\(fn)" t nil)
;;;***
diff --git a/misc/emacs/go-mode.el b/misc/emacs/go-mode.el
index 2624e87cb..692cabfe5 100644
--- a/misc/emacs/go-mode.el
+++ b/misc/emacs/go-mode.el
@@ -498,21 +498,45 @@ Useful for development work."
(require 'go-mode)
(go-mode))
-(provide 'go-mode)
-
+;;;###autoload
(defun gofmt ()
- "Pipe the current buffer through the external tool `gofmt`."
-
- (interactive)
- ;; for some reason save-excursion isn't working
- ;; probably because shell-command-on-region deletes the contents of the
- ;; region before filling in the new values
- ;; so we will save the point/mark by hand
- ;; similarly we can't use push-mark/pop-mark
- (let ((old-mark (mark t)) (old-point (point)))
- (save-restriction
- (let (deactivate-mark)
- (widen)
- (shell-command-on-region (point-min) (point-max) "gofmt" t t shell-command-default-error-buffer)))
- (goto-char (min old-point (point-max)))
- (if old-mark (set-mark (min old-mark (point-max))))))
+ "Pipe the current buffer through the external tool `gofmt`.
+Replace the current buffer on success; display errors on failure."
+
+ (interactive)
+ (let ((srcbuf (current-buffer)))
+ (with-temp-buffer
+ (let ((outbuf (current-buffer))
+ (errbuf (get-buffer-create "*Gofmt Errors*")))
+ (with-current-buffer errbuf (erase-buffer))
+ (with-current-buffer srcbuf
+ (save-restriction
+ (let (deactivate-mark)
+ (widen)
+ (if (= 0 (shell-command-on-region (point-min) (point-max) "gofmt"
+ outbuf nil errbuf))
+ ;; gofmt succeeded: replace the current buffer with outbuf,
+ ;; restore the mark and point, and discard errbuf.
+ (let ((old-mark (mark t)) (old-point (point)))
+ (erase-buffer)
+ (insert-buffer-substring outbuf)
+ (goto-char (min old-point (point-max)))
+ (if old-mark (set-mark (min old-mark (point-max))))
+ (kill-buffer errbuf))
+
+ ;; gofmt failed: display the errors
+ (display-buffer errbuf)))))
+
+ ;; Collapse any window opened on outbuf if shell-command-on-region
+ ;; displayed it.
+ (delete-windows-on outbuf)))))
+
+;;;###autoload
+(defun gofmt-before-save ()
+ "Add this to .emacs to run gofmt on the current buffer when saving:
+ (add-hook 'before-save-hook #'gofmt-before-save)"
+
+ (interactive)
+ (when (eq major-mode 'go-mode) (gofmt)))
+
+(provide 'go-mode)
diff --git a/misc/goplay/goplay.go b/misc/goplay/goplay.go
index 3ca5ed80c..f887fbbda 100644
--- a/misc/goplay/goplay.go
+++ b/misc/goplay/goplay.go
@@ -83,7 +83,7 @@ func Compile(w http.ResponseWriter, req *http.Request) {
}
// write request Body to x.go
- f, err := os.Open(src, os.O_CREAT|os.O_WRONLY|os.O_TRUNC, 0666)
+ f, err := os.Create(src)
if err != nil {
error(w, nil, err)
return
diff --git a/misc/kate/go.xml b/misc/kate/go.xml
index b8ff59267..14d88b26a 100644
--- a/misc/kate/go.xml
+++ b/misc/kate/go.xml
@@ -12,13 +12,13 @@
<list name="keywords">
<item> break </item>
<item> case </item>
+ <item> chan </item>
<item> const </item>
<item> continue </item>
<item> default </item>
<item> defer </item>
<item> else </item>
<item> fallthrough </item>
- <item> false </item>
<item> for </item>
<item> func </item>
<item> go </item>
@@ -26,22 +26,25 @@
<item> if </item>
<item> import </item>
<item> interface </item>
- <item> iota </item>
- <item> nil </item>
+ <item> map </item>
<item> package </item>
<item> range </item>
<item> return </item>
<item> select </item>
<item> struct </item>
<item> switch </item>
- <item> true </item>
<item> type </item>
<item> var </item>
</list>
+ <list name="predeclared">
+ <item> false </item>
+ <item> iota </item>
+ <item> nil </item>
+ <item> true </item>
+ </list>
<list name="types">
<item> bool </item>
<item> byte </item>
- <item> chan </item>
<item> complex64 </item>
<item> complex128 </item>
<item> float32 </item>
@@ -51,7 +54,6 @@
<item> int16 </item>
<item> int32 </item>
<item> int64 </item>
- <item> map </item>
<item> string </item>
<item> uint </item>
<item> uintptr </item>
@@ -64,7 +66,6 @@
<item> append </item>
<item> cap </item>
<item> close </item>
- <item> closed </item>
<item> complex </item>
<item> copy </item>
<item> imag </item>
@@ -81,6 +82,8 @@
<context attribute="Normal Text" lineEndContext="#stay" name="Normal">
<DetectSpaces />
<keyword attribute="Keyword" context="#stay" String="keywords"/>
+ <keyword attribute="Predeclared Identifier" context="#stay"
+ String="predeclared"/>
<keyword attribute="Data Type" context="#stay" String="types"/>
<keyword attribute="Builtin Function" context="#stay" String="functions"/>
<DetectIdentifier />
@@ -119,6 +122,7 @@
<itemDatas>
<itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false"/>
<itemData name="Keyword" defStyleNum="dsKeyword" spellChecking="false"/>
+ <itemData name="Predeclared Identifier" defStyleNum="dsOthers" spellChecking="false"/>
<itemData name="Builtin Function" defStyleNum="dsFunction" spellChecking="false"/>
<itemData name="Data Type" defStyleNum="dsDataType" spellChecking="false"/>
<itemData name="Decimal" defStyleNum="dsDecVal" spellChecking="false"/>
diff --git a/misc/notepadplus/README b/misc/notepadplus/README
new file mode 100755
index 000000000..000d31746
--- /dev/null
+++ b/misc/notepadplus/README
@@ -0,0 +1,8 @@
+Given a Notepad++ installation at <DIR>:
+
+1. Add the contents of userDefineLang.xml at <DIR>\userDefineLang.xml
+ between <NotepadPlus> ... </NotepadPlus>
+
+2. Copy go.xml to <DIR>\plugins\APIs
+
+3. Restart Notepad++
diff --git a/misc/notepadplus/go.xml b/misc/notepadplus/go.xml
new file mode 100755
index 000000000..7c5d8a173
--- /dev/null
+++ b/misc/notepadplus/go.xml
@@ -0,0 +1,66 @@
+<NotepadPlus>
+ <!-- Go Programming Language builtins and keywords -->
+ <AutoComplete>
+ <KeyWord name="append"/>
+ <KeyWord name="bool" />
+ <KeyWord name="break" />
+ <KeyWord name="byte" />
+ <KeyWord name="cap" />
+ <KeyWord name="case" />
+ <KeyWord name="chan" />
+ <KeyWord name="close" />
+ <KeyWord name="complex" />
+ <KeyWord name="complex128" />
+ <KeyWord name="complex64" />
+ <KeyWord name="const" />
+ <KeyWord name="continue" />
+ <KeyWord name="copy" />
+ <KeyWord name="default" />
+ <KeyWord name="defer" />
+ <KeyWord name="else" />
+ <KeyWord name="fallthrough" />
+ <KeyWord name="false" />
+ <KeyWord name="float32" />
+ <KeyWord name="float64" />
+ <KeyWord name="for" />
+ <KeyWord name="func" />
+ <KeyWord name="go" />
+ <KeyWord name="goto" />
+ <KeyWord name="if" />
+ <KeyWord name="iota" />
+ <KeyWord name="imag" />
+ <KeyWord name="import" />
+ <KeyWord name="int" />
+ <KeyWord name="int16" />
+ <KeyWord name="int32" />
+ <KeyWord name="int64" />
+ <KeyWord name="int8" />
+ <KeyWord name="interface" />
+ <KeyWord name="len" />
+ <KeyWord name="make" />
+ <KeyWord name="map" />
+ <KeyWord name="new" />
+ <KeyWord name="nil" />
+ <KeyWord name="package" />
+ <KeyWord name="panic" />
+ <KeyWord name="print" />
+ <KeyWord name="println" />
+ <KeyWord name="range" />
+ <KeyWord name="real" />
+ <KeyWord name="recover" />
+ <KeyWord name="return" />
+ <KeyWord name="select" />
+ <KeyWord name="string" />
+ <KeyWord name="struct" />
+ <KeyWord name="switch" />
+ <KeyWord name="true" />
+ <KeyWord name="type" />
+ <KeyWord name="uint" />
+ <KeyWord name="uint16" />
+ <KeyWord name="uint32" />
+ <KeyWord name="uint64" />
+ <KeyWord name="uint8" />
+ <KeyWord name="uintptr" />
+ <KeyWord name="var" />
+ </AutoComplete>
+</NotepadPlus>
diff --git a/misc/notepadplus/userDefineLang.xml b/misc/notepadplus/userDefineLang.xml
new file mode 100755
index 000000000..d1927a340
--- /dev/null
+++ b/misc/notepadplus/userDefineLang.xml
@@ -0,0 +1,36 @@
+<!-- <NotepadPlus> -->
+ <UserLang name="go" ext="go">
+ <Settings>
+ <Global caseIgnored="no" />
+ <TreatAsSymbol comment="no" commentLine="no" />
+ <Prefix words1="no" words2="no" words3="no" words4="no" />
+ </Settings>
+ <KeywordLists>
+ <Keywords name="Delimiters">&quot;`0&quot;`</Keywords>
+ <Keywords name="Folder+"></Keywords>
+ <Keywords name="Folder-"></Keywords>
+ <Keywords name="Operators">( ) [ ] { } ... . , _ &amp; ^ % &gt; &lt; ! = + - * | :</Keywords>
+ <Keywords name="Comment"> 1/* 2*/ 0//</Keywords>
+ <Keywords name="Words1">append bool break byte cap case chan close complex complex128 complex64 const continue copy default defer else fallthrough false float32 float64 for func go goto if iota imag import int int16 int32 int64 int8 interface len make map new nil package panic print println range real recover return select string struct switch true type uint uint16 uint32 uint64 uint8 uintptr var</Keywords>
+ <Keywords name="Words2"></Keywords>
+ <Keywords name="Words3"></Keywords>
+ <Keywords name="Words4"></Keywords>
+ </KeywordLists>
+ <Styles>
+ <WordsStyle name="DEFAULT" styleID="11" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ <WordsStyle name="FOLDEROPEN" styleID="12" fgColor="FFFF00" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ <WordsStyle name="FOLDERCLOSE" styleID="13" fgColor="0B243B" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ <WordsStyle name="KEYWORD1" styleID="5" fgColor="AA0000" bgColor="FFFFFF" fontName="" fontStyle="1" />
+ <WordsStyle name="KEYWORD2" styleID="6" fgColor="AA0000" bgColor="FFFFFF" fontName="" fontStyle="1" />
+ <WordsStyle name="KEYWORD3" styleID="7" fgColor="AA0000" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ <WordsStyle name="KEYWORD4" styleID="8" fgColor="A00000" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ <WordsStyle name="COMMENT" styleID="1" fgColor="AAAAAA" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ <WordsStyle name="COMMENT LINE" styleID="2" fgColor="AAAAAA" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ <WordsStyle name="NUMBER" styleID="4" fgColor="A52A2A" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ <WordsStyle name="OPERATOR" styleID="10" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="1" />
+ <WordsStyle name="DELIMINER1" styleID="14" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ <WordsStyle name="DELIMINER2" styleID="15" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ <WordsStyle name="DELIMINER3" styleID="16" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="0" />
+ </Styles>
+ </UserLang>
+<!-- </NotepadPlus> -->
diff --git a/misc/swig/callback/Makefile b/misc/swig/callback/Makefile
new file mode 100644
index 000000000..fde0d107b
--- /dev/null
+++ b/misc/swig/callback/Makefile
@@ -0,0 +1,17 @@
+# Copyright 2011 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+include ../../../src/Make.inc
+
+TARG=swig/callback
+SWIGFILES=\
+ callback.swigcxx
+
+CLEANFILES+=run
+
+include ../../../src/Make.pkg
+
+%: install %.go
+ $(GC) $*.go
+ $(LD) $(SWIG_RPATH) -o $@ $*.$O
diff --git a/misc/swig/callback/callback.h b/misc/swig/callback/callback.h
new file mode 100644
index 000000000..80232a8b3
--- /dev/null
+++ b/misc/swig/callback/callback.h
@@ -0,0 +1,24 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+class Callback {
+public:
+ virtual ~Callback() { }
+ virtual std::string run() { return "Callback::run"; }
+};
+
+class Caller {
+private:
+ Callback *callback_;
+public:
+ Caller(): callback_(0) { }
+ ~Caller() { delCallback(); }
+ void delCallback() { delete callback_; callback_ = 0; }
+ void setCallback(Callback *cb) { delCallback(); callback_ = cb; }
+ std::string call() {
+ if (callback_ != 0)
+ return callback_->run();
+ return "";
+ }
+};
diff --git a/misc/swig/callback/callback.swigcxx b/misc/swig/callback/callback.swigcxx
new file mode 100644
index 000000000..0c97ef101
--- /dev/null
+++ b/misc/swig/callback/callback.swigcxx
@@ -0,0 +1,18 @@
+/* Copyright 2011 The Go Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style
+ license that can be found in the LICENSE file. */
+
+/* An example of writing a C++ virtual function in Go. */
+
+%module(directors="1") callback
+
+%{
+#include <string>
+#include "callback.h"
+%}
+
+%include "std_string.i"
+
+%feature("director");
+
+%include "callback.h"
diff --git a/misc/swig/callback/run b/misc/swig/callback/run
new file mode 100755
index 000000000..de150ed05
--- /dev/null
+++ b/misc/swig/callback/run
Binary files differ
diff --git a/misc/swig/callback/run.go b/misc/swig/callback/run.go
new file mode 100644
index 000000000..a76e636cb
--- /dev/null
+++ b/misc/swig/callback/run.go
@@ -0,0 +1,39 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "swig/callback"
+ "fmt"
+)
+
+type GoCallback struct{}
+
+func (p *GoCallback) Run() string {
+ return "GoCallback.Run"
+}
+
+func main() {
+ c := callback.NewCaller()
+ cb := callback.NewCallback()
+
+ c.SetCallback(cb)
+ s := c.Call()
+ fmt.Println(s)
+ if s != "Callback::run" {
+ panic(s)
+ }
+ c.DelCallback()
+
+ cb = callback.NewDirectorCallback(&GoCallback{})
+ c.SetCallback(cb)
+ s = c.Call()
+ fmt.Println(s)
+ if s != "GoCallback.Run" {
+ panic(s)
+ }
+ c.DelCallback()
+ callback.DeleteDirectorCallback(cb)
+}
diff --git a/misc/swig/stdio/Makefile b/misc/swig/stdio/Makefile
new file mode 100644
index 000000000..e7d330587
--- /dev/null
+++ b/misc/swig/stdio/Makefile
@@ -0,0 +1,17 @@
+# Copyright 2011 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+include ../../../src/Make.inc
+
+TARG=swig/file
+SWIGFILES=\
+ file.swig
+
+CLEANFILES+=hello
+
+include ../../../src/Make.pkg
+
+%: install %.go
+ $(GC) $*.go
+ $(LD) $(SWIG_RPATH) -o $@ $*.$O
diff --git a/misc/swig/stdio/file.swig b/misc/swig/stdio/file.swig
new file mode 100644
index 000000000..57c623f8f
--- /dev/null
+++ b/misc/swig/stdio/file.swig
@@ -0,0 +1,11 @@
+/* Copyright 2011 The Go Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style
+ license that can be found in the LICENSE file. */
+
+/* A trivial example of wrapping a C library using SWIG. */
+
+%{
+#include <stdio.h>
+%}
+
+int puts(const char *);
diff --git a/misc/swig/stdio/hello b/misc/swig/stdio/hello
new file mode 100755
index 000000000..10c55631f
--- /dev/null
+++ b/misc/swig/stdio/hello
Binary files differ
diff --git a/misc/swig/stdio/hello.go b/misc/swig/stdio/hello.go
new file mode 100644
index 000000000..eec294278
--- /dev/null
+++ b/misc/swig/stdio/hello.go
@@ -0,0 +1,11 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import "swig/file"
+
+func main() {
+ file.Puts("Hello, world")
+}
diff --git a/misc/vim/ftplugin/go/fmt.vim b/misc/vim/ftplugin/go/fmt.vim
new file mode 100644
index 000000000..18a2156f5
--- /dev/null
+++ b/misc/vim/ftplugin/go/fmt.vim
@@ -0,0 +1,30 @@
+" Copyright 2011 The Go Authors. All rights reserved.
+" Use of this source code is governed by a BSD-style
+" license that can be found in the LICENSE file.
+"
+" fmt.vim: Vim command to format Go files with gofmt.
+"
+" This filetype plugin add a new commands for go buffers:
+"
+" :Fmt
+"
+" Filter the current Go buffer through gofmt.
+" It tries to preserve cursor position and avoids
+" replacing the buffer with stderr output.
+"
+
+command! Fmt call s:GoFormat()
+
+function! s:GoFormat()
+ let view = winsaveview()
+ %!gofmt
+ if v:shell_error
+ %| " output errors returned by gofmt
+ " TODO(dchest): perhaps, errors should go to quickfix
+ undo
+ echohl Error | echomsg "Gofmt returned error" | echohl None
+ endif
+ call winrestview(view)
+endfunction
+
+" vim:ts=4:sw=4:et
diff --git a/misc/vim/indent/go.vim b/misc/vim/indent/go.vim
new file mode 100644
index 000000000..2e9f191f5
--- /dev/null
+++ b/misc/vim/indent/go.vim
@@ -0,0 +1,30 @@
+" Copyright 2011 The Go Authors. All rights reserved.
+" Use of this source code is governed by a BSD-style
+" license that can be found in the LICENSE file.
+"
+" indent/go.vim: Vim indent file for Go.
+"
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+" C indentation is mostly correct
+setlocal cindent
+
+" Options set:
+" +0 -- Don't indent continuation lines (because Go doesn't use semicolons
+" much)
+" L0 -- Don't move jump labels (NOTE: this isn't correct when working with
+" gofmt, but it does keep struct literals properly indented.)
+" :0 -- Align case labels with switch statement
+" l1 -- Always align case body relative to case labels
+" J1 -- Indent JSON-style objects (properly indents struct-literals)
+" (0, Ws -- Indent lines inside of unclosed parentheses by one shiftwidth
+" m1 -- Align closing parenthesis line with first non-blank of matching
+" parenthesis line
+"
+" Known issue: Trying to do a multi-line struct literal in a short variable
+" declaration will not indent properly.
+setlocal cinoptions+=+0,L0,:0,l1,J1,(0,Ws,m1
diff --git a/misc/vim/readme.txt b/misc/vim/readme.txt
index f836f58f3..3c3255113 100644
--- a/misc/vim/readme.txt
+++ b/misc/vim/readme.txt
@@ -35,3 +35,16 @@ To install one of the available filetype plugins for Go:
3. Add the following line to your .vimrc file (normally $HOME/.vimrc):
filetype plugin on
+
+
+Vim indentation plugin for Go
+=============================
+
+To install automatic indentation for Go:
+
+ 1. Same as 1 above.
+ 2. Copy or link indent/go.vim to the indent directory underneath your vim
+ runtime directory (normally $HOME/.vim/indent).
+ 3. Add the following line to your .vimrc file (normally $HOME/.vimrc):
+
+ filetype indent on
diff --git a/misc/vim/syntax/go.vim b/misc/vim/syntax/go.vim
index 7507cada2..26d7defe3 100644
--- a/misc/vim/syntax/go.vim
+++ b/misc/vim/syntax/go.vim
@@ -85,7 +85,7 @@ syn match goType /\<func\>/
syn match goDeclaration /^func\>/
" Predefined functions and values
-syn keyword goBuiltins append cap close closed complex copy imag len
+syn keyword goBuiltins append cap close complex copy imag len
syn keyword goBuiltins make new panic print println real recover
syn keyword goConstants iota true false nil
@@ -181,7 +181,7 @@ if go_highlight_extra_types != 0
syn match goExtraType /\<bytes\.\(Buffer\)\>/
syn match goExtraType /\<io\.\(Reader\|Writer\|ReadWriter\|ReadWriteCloser\)\>/
syn match goExtraType /\<\(os\.Error\)\>/
- syn match goExtraType /\<reflect\.\w*\(Type\|Value\)\>/
+ syn match goExtraType /\<reflect\.\(Kind\|Type\|Value\)\>/
syn match goExtraType /\<unsafe\.Pointer\>/
endif