
Go 1.8 Release Notes - petercooper
https://beta.golang.org/doc/go1.8
======
grey-area
OK, so now this is out, how about we discuss what is actually in this release!

The sort pkg now has a convenience for sorting slices, which will be a nice
shortcut instead of having to define a special slice type just to sort on a
given criteria, you can just pass a sorting function instead.

HTTP/2 Push is now in the server, which is fun, but like context might take a
while for people to start using in earnest. Likewise graceful shutdown. Is
anyone experimenting with this yet?

Plugins are here, but on Linux only for now - this will be interesting long
term for things like server software which wants to let other compile plugins
for it and distribute them separately, presently that has to be compiled in to
the main binary.

Performance: GC times are now down to 10-100 microseconds, and defer and cgo
are also faster. Compilation time improving but still not close to 1.4.

GOPATH is optional now, but you still do need a path where all go code is
kept, perhaps eventually this requirement will go away - GOPATH/pkg is just a
cache, GOPATH/bin is just an install location, and GOPATH/src could really be
anywhere, so I'm not sure if long term a special go directory is required at
all if vendoring takes off, then import paths could be project-local.

There's a slide deck here with a rundown of all the changes from Dave Cheney:

[https://talks.godoc.org/github.com/davecheney/go-1.8-release...](https://talks.godoc.org/github.com/davecheney/go-1.8-release-
party/presentation.slide#1)

Finally, as someone using Go for work and play, thanks to the Go team and
everyone who contributed to this release. I really appreciate the incremental
but significant changes in every release, and the stability of the core
language.

~~~
justinsaccount
> The sort pkg now has a convenience for sorting slices, which will be a nice
> shortcut instead of having to define a special slice type just to sort on a
> given criteria, you can just pass a sorting function instead.

So you can do this now:

    
    
      sort.Slice(people, func(i, j int) bool { return people[i].Name < people[j].Name })
    

But what I think most people want is.

    
    
      sort.Slice(people, func(p Person) string { return p.Name })
    

Since that lends to things like this:

    
    
      //Sort first by age and then by name
      sort.Slice(people, func(p Person) (int, string) { return p.Age, p.Name })

~~~
grey-area
They have sort.SliceStable for this I think, it's not much more verbose and is
arguably clearer and more flexible as you can define exactly how the keys are
compared (for example perhaps you want to downcase names before compare).

Compare the old way to do a multi-key sort:

[https://play.golang.org/p/NJTVoeQkMt](https://play.golang.org/p/NJTVoeQkMt)

With the new way:

[https://play.golang.org/p/6ReQxHT1lR](https://play.golang.org/p/6ReQxHT1lR)

it's a lot simpler and clearer and doesn't require a special slice type (as it
did before), but lets you sort on multiple keys if you need to. Presumably
sort.SliceStable is a bit slower and that's why they have a separate
sort.Slice.

Note though that the old way using slice types does let you do something
neater at the point of use at the cost of more setup:

    
    
        OrderedBy(language, increasingLines, user).Sort(changes)
    

which in some ways is more similar to what you desired?

Seeing this sort of hack added does make me think containers are the one big
weak point in Go at present, they are a bit ugly, and special cases abound
(append,delete,range,sort) - maybe in Go2 they could have something neater,
more generic and more extensible. My hopes for Go 2 as a really uninformed
language noob are a tidy up of the stdlib, variants and more elegant ways to
manipulate containers (I won't say generics!), I would love to see things like
magic comments and struct tags disappear too but that'll never happen. I'm
pretty happy with the language otherwise, and would actually like to see Go
get smaller and simpler over time.

~~~
justinsaccount
ah, SliceStable does make it a little easier at least. I'd say you could just
wrap that in a function, but you can't easily do that.

Sorting is probably the one area where I really miss generics in go.. because
comparing and sorting IS such a generic thing to do. In my head I think, "Oh,
so I just want to do

    
    
      hosts.sort(key=operator.attrgetter("os", "version", "address"))
    

and then proceed to write the 20 lines of code that lets me do that :-(

~~~
grey-area
Just thought of one more way to do this which is neater - define functions on
a simpler slice type:

[https://play.golang.org/p/0YcxA-Ufs-](https://play.golang.org/p/0YcxA-Ufs-)

So your sorting becomes quite neat:

    
    
        sort.SliceStable(changes,changes.byLines)
        sort.SliceStable(changes,changes.byUser)
    

I think I might use it this way (haven't actually used this in a real app
yet).

~~~
SaidinWoT
Perhaps something combining all of the things you've made use of?
[https://play.golang.org/p/8RDqjjZDB8](https://play.golang.org/p/8RDqjjZDB8)

------
clumsysmurf
I'm wondering if "The Go Programming Language 1e" (Donovan / Kernighan) is
still relevant enough to be used as a first book for self teaching.

[https://www.amazon.com/Programming-Language-Addison-
Wesley-P...](https://www.amazon.com/Programming-Language-Addison-Wesley-
Professional-Computing/dp/0134190440)

~~~
alpb
I personally learned Go about 3.5 years ago myself by following tutorials on
tour.golang.org, reading the Effective Go document and other blog posts here
and there. Then I bought the book last year just out of curiosity. Honestly I
find that the experience you gain by reading/writing Go code and consuming
online content is more beneficial than the book. The book has some good parts,
but I don't think it’s as practical as online resources.

~~~
sotojuan
> Honestly I find that the experience you gain by reading/writing Go code and
> consuming online content is more beneficial than the book.

This applies to almost all languages and technologies!

~~~
krylon
Yes, but sometimes it is much easier to get moving with a good textbook.

With Go, a few online tutorials and the documentation that comes with Go
itself, were all I needed to get going. I am not sure if that was an explicit
design goal, but I found the language very easy to learn.

~~~
alpb
I believe it was an explicit design goal. They wanted new employees joining
from straight out of college to be effective within Google's codebase as soon
as possible. Therefore the learning curve is pretty low if you already know
another mainstream programming language.

------
jbergstroem
I reckon h2 push
([https://beta.golang.org/doc/go1.8#h2push](https://beta.golang.org/doc/go1.8#h2push))
support will be big for web servers like caddy and traefik.

Caddy already has a few interesting ideas on how to use this:
[https://github.com/mholt/caddy/pull/1215#issuecomment-256360...](https://github.com/mholt/caddy/pull/1215#issuecomment-256360674)

------
0xmohit
What is new in Go 1.8: [http://www.slideshare.net/huazhihao1/what-is-new-in-
go-18-72...](http://www.slideshare.net/huazhihao1/what-is-new-in-
go-18-72210978)

~~~
matt4077
Best text version I found:
[https://github.com/golang/go/blob/master/doc/go1.8.html](https://github.com/golang/go/blob/master/doc/go1.8.html)

~~~
ainar-g
You mean [https://tip.golang.org/doc/go1.8](https://tip.golang.org/doc/go1.8)?

------
old-gregg
1.7 release was great for finally addressing the issue of ever-growing size of
produced binaries. [1] Moreover, some additional improvements were promised in
1.8 which I was looking forward to.

But after upgrading to 1.8 I am now observing 3-4% binary increase vs 1.7, so
the trend is again reversed back to fatter binaries. :(

[1] [https://blog.golang.org/go1.7-binary-
size](https://blog.golang.org/go1.7-binary-size)

~~~
OrangeTux
You can use upx[1] to compress the binaries. I usually can shrink my binaries
by 75%.

Read more on this[2] blog post.

1: [https://upx.github.io/](https://upx.github.io/)

2: [https://blog.filippo.io/shrink-your-go-binaries-with-this-
on...](https://blog.filippo.io/shrink-your-go-binaries-with-this-one-weird-
trick/)

------
modeless
I see stop-the-world garbage collection pause times have been reduced to
microseconds which is great. But for many applications the pause times for
single threads still matter. Any numbers for that?

------
KAdot
Official release blog post
[https://blog.golang.org/go1.8](https://blog.golang.org/go1.8).

------
gravelc
I'm seeing significant performance increases in my app (small RNA aligner).
Haven't profiled yet, so not sure where the gains are coming from, but happy
all the same.

------
speps
> The DefaultTransport.Dialer now enables DualStack ("Happy Eyeballs"[1])
> support, allowing the use of IPv4 as a backup if it looks like IPv6 might be
> failing

[1] [https://tools.ietf.org/html/rfc6555](https://tools.ietf.org/html/rfc6555)

------
claudiug
[http://www.slideshare.net/huazhihao1/what-is-new-in-
go-18-72...](http://www.slideshare.net/huazhihao1/what-is-new-in-
go-18-72210978)

so go is becoming more and more better for lower GC tasks

------
dyu-
Looking at the c ffi improvements posted, I thought I'd check if there were
improvements.

Time in ms to call a c function 2 billion times (lesser is better).

95536 - go 1.1.2

130105 - go 1.8.0

It is a rather crude example:

// plusone is the ffi

int x = 0;

while (x < 2000000000) x = plusone(x);

Here's the source [https://github.com/dyu/ffi-
overhead](https://github.com/dyu/ffi-overhead)

With other programming languages:

c:

4778

nim:

4746

rust:

5331

java7:

17922

java8:

17992

go:

130105

(edited for formatting)

~~~
dpc_pw
Small stacks used for goroutines don't play well with calling C functions
which assume huge stacks. That's price you pay for having nice scalability
story. There might be other issues, which come from the fact that Go has
elaborated runtime.

~~~
dyu-
Yea it was a toy example. Still the overhead is steep for applications that
call c ffi often.

The workaround is usually to batch your computations on the c-side (micro-rpc)
and minimize the calls (like cockroachdb is doing)

------
tandr
Folks, can someone enlighten me on how new Argument Liveness
[https://golang.org/doc/go1.8#liveness](https://golang.org/doc/go1.8#liveness)
works ?

I mean, so now if you are in the middle of a long function, you cannot be sure
anymore if parameters passed to that function are not GC'd? Or compiler does
some hinting on "ooh, this param is not used after that point in function,
lets mark it as `ready for GC`?

------
tempw
A little not so related question, what is/are the most used stack for web
applications in Go? How common if at all would be a Go backend & React for
instance frontend stack?

~~~
oelmekki
I can't tell about "how common", but a react web client with a go backend API
is exactly what I do on my main product, currently.

It still has a few problems I haven't managed to solve, though (but not
related directly to go). For example, given the visible routing is handled by
react-router, I haven't find a way yet to issue proper 404 status (I have a
catchall route that renders web client page, then client router displays a
"not found" page, but it will be a 200 status). Not that a big deal, because
the web client is an application behind auth, and not some public facing
pages.

~~~
hellcow
Another great 3rd party router is Chi.
[https://github.com/pressly/chi](https://github.com/pressly/chi)

My company uses httprouter, but if Chi had been available when we started,
we'd have used that instead. It follows Go's standard library API (httprouter
diverges a little bit with its params) and adds support for Go's Context
(which httprouter currently lacks).

~~~
AsyncAwait
I've been using gorilla's mux, precisely because it follows the stdlib API,
will certainly have a look at Chi, thanks for the link.

------
Ice32
Why is the latest stable version on their website still 1.7.5? Where can I
download 1.8 installation for linux (not source code)?

I've just removed my previous version and then I realize there's no 1.8 on
their website.

~~~
AsyncAwait
What linux distro are you on? Most people on Linux tend to use their package
managers to get updates, or is your distro too far behind on Go?

~~~
Ice32
I'm using xubuntu, how do I manage go through package manager?

~~~
jerf
I use godeb:
[https://github.com/niemeyer/godeb](https://github.com/niemeyer/godeb)

It packages the go release into .deb files, which you then can manage using
standard Debian tools.

Note that since it scrapes the release page for what releases are available,
it won't be able to download 1.8 until it, you know, has actually been
released, and sometimes the release page changes format upon a new release and
it may take a bit for godeb to be updated.

~~~
Ice32
I've just installed 1.8 through godeb, thank you!

------
jraedisch
I am just leaving the release party in Hamburg, Germany and looking forward to
simpler sorting and all the other improvements. Awesome stuff and awesome
people!

------
enahs-sf
random question here, but what are people using in the way of ORM/sql access
with go? Just database/sql or are there any other good packages worth checking
out. I don't expect a full-blown activerecord style ORM, but something that
takes a bit of the pain out of mapping structs to records.

~~~
n0w
I've been looking forward to 1.8 to solve this problem. I wrote a small tool
using the new `ColumnType` info that takes my SQL queries and generates code
to query the database and unmarshal rows into an array of structs.

~~~
cenanozen
I would love to see that tool

------
watbe
Final release notes:
[https://golang.org/doc/go1.8](https://golang.org/doc/go1.8)

------
perseusprime11
What is the best place to start if I want to learn Go? Any books? Tutorials?

~~~
sethammons
Take the tour on their site. Check out gobyexample after that. Then read
effective go.

------
bitmapbrother
Does anyone know the roadmap for Go 1.9?

~~~
grey-area
There's some stuff at the end of these slides

[https://talks.godoc.org/github.com/davecheney/go-1.8-release...](https://talks.godoc.org/github.com/davecheney/go-1.8-release-
party/presentation.slide#1)

------
0xdeadbeefbabe
Yay Mips32!

------
schmichael
Linking to the Github release seems more like a grab for fake Internet points
than a useful post.

A useful post would be waiting for golang.org to be updated and linking to the
official release notes.

Edit: Thanks to whoever updated the link to point to something useful at
least. Still would have preferred this came down until the release was
actually posted.

~~~
petercooper
An unfair, groundless projection on your part. Thanks for spreading a little
more negativity today :-)

From the HN guidelines: _Please don 't submit comments complaining that a
submission is inappropriate for the site._

~~~
schmichael
I'm as excited as the next gopher about Go 1.8's release, but for all
practical purposes it hasn't been released yet. It's actually an incredibly
frustrating submission for those of us excited to get the official binaries.

------
eknkc
Draft release notes:
[https://beta.golang.org/doc/go1.8](https://beta.golang.org/doc/go1.8)

~~~
sctb
Thanks, we've updated the link from
[https://github.com/golang/go/releases](https://github.com/golang/go/releases).

------
wyager
Not really, since there's a risk of new people deciding to use it whenever it
comes up. It would be silly to say "alright, we get it, cigarettes are bad for
you, can we stop harping on this please?"

~~~
dang
Please don't do programming language flamewars on HN.

We detached this subthread from
[https://news.ycombinator.com/item?id=13662583](https://news.ycombinator.com/item?id=13662583)
and marked it off-topic.

~~~
wyager
I was responding to "it's kind of useless to be beating the language up upon
every release". My comment applies to literally any programming language
release or other product release notification; it makes sense for people to
discuss the pros and cons of a product every time it comes up, because A)
things change and B) it might be the first time that someone has come across
the product.

If minor version release notes are on-topic enough to get posted every single
time, I'm not really sure how an attached discussion of the product in
question (possibly involving criticism) isn't.

------
rshetty10
Hurray, Finally

