release.2010-03-30

57 views
Skip to first unread message

Andrew Gerrand

unread,
Mar 30, 2010, 11:46:38 PM3/30/10
to golang-nuts
We've just tagged a new Go release, release.2010-03-30. As usual, you
can update by running:
hg pull
hg update release

This release contains three language changes:

1. Accessing a non-existent key in a map is no longer a run-time error.
It now evaluates to the zero value for that type. For example:
x := myMap[i] is now equivalent to: x, _ := myMap[i]

2. It is now legal to take the address of a function's return value.
The return values are copied back to the caller only after deferred
functions have run.

3. The functions panic and recover, intended for reporting and recovering from
failure, have been added to the spec:
http://golang.org/doc/go_spec.html#Handling_panics
In a related change, panicln is gone, and panic is now a single-argument
function. Panic and recover are recognized by the gc compilers but the new
behavior is not yet implemented.

The ARM build is broken in this release; ARM users should stay at
release.2010-03-22.

Other changes:
* bytes, strings: add IndexAny.
* cc/ld: Add support for #pragma dynexport,
Rename dynld to dynimport throughout. Cgo users will need to rerun cgo.
* expvar: default publishings for cmdline, memstats
* flag: add user-defined flag types.
* gc: usual bug fixes
* go/ast: generalized ast filtering.
* go/printer: avoid reflect in print.
* godefs: fix handling of negative constants.
* godoc: export pprof debug information, exported variables,
support for filtering of command-line output in -src mode,
use http GET for remote search instead of rpc.
* gofmt: don't convert multi-line functions into one-liners,
preserve newlines in multiline selector expressions (thanks
Risto Jaakko Saarelma).
* goinstall: include command name in error reporting (thanks Andrey Mirtchovski)
* http: add HandleFunc as shortcut to Handle(path, HandlerFunc(func))
* make: use actual dependency for install
* math: add J1, Y1, Jn, Yn, J0, Y0 (Bessel functions) (thanks Charles L. Dorian)
* prof: add pprof from google-perftools
* regexp: don't return non-nil *Regexp if there is an error.
* runtime: add Callers,
add malloc sampling, pprof interface,
add memory profiling, more statistics to runtime.MemStats,
implement missing destroylock() (thanks Alex Brainman),
more malloc statistics,
run all finalizers in a single goroutine,
Goexit runs deferred calls.
* strconv: add Atob and Btoa,
Unquote could wrongly return a nil error on error (thanks Roger Peppe).
* syscall: add IPV6 constants,
add syscall_bsd.go for Darwin and other *BSDs (thanks Giles Lean),
implement SetsockoptString (thanks Christopher Wedgwood).
* websocket: implement new protocol (thanks Fumitoshi Ukai).
* xgb: fix request length and request size (thanks Firmansyah Adiputra).
* xml: add CopyToken (thanks Kyle Consalus),
add line numbers to syntax errors (thanks Kyle Consalus),
use io.ReadByter in place of local readByter (thanks Raif S. Naffah).

Apologies if we missed anyone in the above list. We appreciate all your help.

To see a full list of changes between this and the previous release,
after updating, run:
hg log -r release.2010-03-22:release.2010-03-30

Enjoy.

Andrew

Daniel Smith

unread,
Mar 31, 2010, 1:20:34 AM3/31/10
to Andrew Gerrand, golang-nuts
Thanks a bunch for #2!



--
To unsubscribe, reply using "remove me" as the subject.



--
Daniel Smith
http://www.schaumburggoclub.org/

Roger Pau Monné

unread,
Mar 31, 2010, 6:04:30 AM3/31/10
to Daniel Smith, Andrew Gerrand, golang-nuts
I think I liked #1 how it was, but anyway... I doesn't make much sense to me to return the default value for an element that's not even on the map.

2010/3/31 Daniel Smith <luken...@gmail.com>

roger peppe

unread,
Mar 31, 2010, 6:27:56 AM3/31/10
to Roger Pau Monné, Daniel Smith, Andrew Gerrand, golang-nuts
On 31 March 2010 10:04, Roger Pau Monné <roy...@gmail.com> wrote:
> I think I liked #1 how it was, but anyway... I doesn't make much sense to me
> to return the default value for an element that's not even on the map.

it's great when there's an unambiguous zero value, such as nil.

for instance, adding an element to a map
of linked lists is one line not two,

m["foo"] = list{value: 999, next: m["foo"]}

and m[x] can be used in an expression without guarding
it with a previous assignment clause, which is often
very convenient:

Esko Luontola

unread,
Apr 1, 2010, 3:41:35 PM4/1/10
to golang-nuts
On Mar 31, 6:46 am, Andrew Gerrand <a...@golang.org> wrote:
> * runtime: add Callers,
>         add malloc sampling, pprof interface,
>         add memory profiling, more statistics to runtime.MemStats,
>         implement missing destroylock() (thanks Alex Brainman),
>         more malloc statistics,
>         run all finalizers in a single goroutine,
>         Goexit runs deferred calls.

Has the definition of runtime.Caller changed? The code in
http://github.com/orfjackal/gospec/blob/40edf318e428da1e417a122f7f98de6fb16e5d13/src/gospec/location.go
used to work correctly when it had runtime.Caller(n + 1) but now after
upgrading to release.2010-03-30 it must be changed to runtime.Caller(n
+ 2)

Russ Cox

unread,
Apr 6, 2010, 1:56:29 AM4/6/10
to Esko Luontola, golang-nuts
> Has the definition of runtime.Caller changed?

No, it's a bug.

Russ

Russ Cox

unread,
Apr 6, 2010, 2:02:53 AM4/6/10
to Andrew Gerrand, golang-nuts
Just to expand on one of the things in the release notes.

This release added support for memory profiling of
running Go programs in the 6g and 8g compilers, so
that you can see where your memory is going.
The profiling uses a variant of the "pprof" tool from
http://code.google.com/p/google-perftools/ which is
installed during the build as "gopprof".
The perftools web page has more about how to use
pprof, but if you were to start godoc --http=:6060
and then run

$ pprof --web http://localhost:6060/debug/pprof/heap

you'd find your web browser loading a page that looks like
http://swtch.com/~rsc/godoc.svg . You can pan in the
profile by clicking and dragging. Zoom using the scroll wheel.

Russ

chris dollin

unread,
Apr 6, 2010, 4:02:55 AM4/6/10
to r...@golang.org, Andrew Gerrand, golang-nuts
I had to fiddle a little to get this to work.

Dependency: needs dot. I installed graphviz to get it. (No, I
don't know why I hadn't already done that for other reasons ...)

The browser launch failed. Runweb says "could not run
web browser". I have firefox and it's on my path and mentioned
in the @alt list. I don't speak Perl so I don't know exactly what
if (-f whatever) means -- I guess an existence test -- so on a
guess I changed the "firefox" entry to "/usr/bin/firefox" and
tried again -- it worked.

This is FC 11 running 8e71a381c9ed+ tip on a 32bit x86.

Could easily be operator error but if so the operator would
like to know what to do right.

Next: understanding the pretty picture!

Chris

--
Chris "allusive" Dollin

Kevin Ballard

unread,
Apr 6, 2010, 3:00:02 PM4/6/10
to chris dollin, r...@golang.org, Andrew Gerrand, golang-nuts

(-f foo) in perl is the same as [[ -f foo ]] in bash, i.e. it tests if
the given file exists and is a regular file. It does not search PATH
for the argument, it treats it as a (absolute|relative) path.

-Kevin Ballard


--
Kevin Ballard
http://kevin.sb.org
kbal...@gmail.com

Reply all
Reply to author
Forward
0 new messages