Go 1.8 Release Notes
beta.golang.org
beta.golang.org
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...
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.
It's worth noting that this is mostly the result of an automatic translation from C to Go, which made the compiler slower, but also a lot more accessible to outside contributions.
The documentation says Linux only but the build flags seem to suggest it may work on macOS?
https://golang.org/src/plugin/plugin_dlopen.go:
// +build linux,cgo darwin,cgo
Can someone with a Mac confirm?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 }) a := ReverseOrder(10)
b := ReverseOrder(20)
a < b // false
sort.Slice(people, func(p Person) string { return ReverseOrder(p.Name) })
Comparison functions are just not very user friendly when what you really want to do is just sort naturally based on a list of fields. sort.Slice(people, func(p Person) (string, string, string, int) { return p.Country, P.Gender, p.Name, p.Age })
turns into a pretty messy comparison function.Not to mention, the key func aka DSU[1] approach is much faster when the comparison function is expensive to call.. imagine something like
sort.Slice(numbers, func(i, j int) bool { return num_factors(numbers[i]) < num_factors(numbers[j]) })
vs. sort.Slice(numbers, func(n int) int { return num_factors(n) })
One needs manual memoizing or caching of this function call, the other can do it internally in a much simpler manor.Compare the old way to do a multi-key sort:
https://play.golang.org/p/NJTVoeQkMt
With the new way:
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.
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 :-(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). GOPATH is optional now
GOPATH isn't optional; it just has a default value now.If you're using anything in a vendor folder, you still need to set GOPATH to a parent folder of your /src/project.
ie. `vendor` is still ignored if it is outside GOPATH; and if you don't set GOPATH, it just defaults to `$HOME/go`. If you ignore GOPATH and don't set it, your code won't build.
You still need GOPATH for now.
(once vendor can exist outside of GOPATH we can really start moving forwards with things)
Maybe? I think broadly the answer is yes, but not very soon.
It'll probably be a timeline like:
- Sometime between now and 1.10 / 1.11 - allow vendor outside of GOPATH
- 1.11 / 1.12 - dep formally becomes part of the go toolchain
- 1.12+ ?? - GOPATH stops existing or significantly changes form.
I'm just speculating based on the progress of dep and the discussions in various issue trackers.Nothing is going into 1.9; it's not ready yet even as a candidate feature. 1.10 could see some changes, and beyond that there will definitely be some kind of changes.
...but probably not this year.
I'm confident they will gradually get rid of it. It was a convenient crutch at first but for those outside a mono repo quite limiting.
https://www.amazon.com/Programming-Language-Addison-Wesley-P...
Go, the language, changed very little since 1.0, most of the improvements have been done on the runtime, GC latency and such.
This applies to almost all languages and technologies!
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.
Caddy already has a few interesting ideas on how to use this: https://github.com/mholt/caddy/pull/1215#issuecomment-256360...
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. :(
Read more on this[2] blog post.
2: https://blog.filippo.io/shrink-your-go-binaries-with-this-on...
so go is becoming more and more better for lower GC tasks
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
With other programming languages:
c:
4778
nim:
4746
rust:
5331
java7:
17922
java8:
17992
go:
130105
(edited for formatting)
The workaround is usually to batch your computations on the c-side (micro-rpc) and minimize the calls (like cockroachdb is doing)
Afterall, nim generates c files.
What's interesting is the nrvo optimizations that nim generates under the hood without much effort from the developer (on non-trivial codebases).
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`?
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.
No, I'll have to think about whether it's worth it adding a whole SSR stack just for that, in my app behind auth :)
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).
But then again, when you have static pages for public facing (and indexed) pages, and you have proper http status for api requests, having or not http status on web client urls is not that a big deal, so that's probably why it's not often mentioned.
The only problem it could cause is if someone makes a deep link to somewhere in your app, it will return a 200 status and will be indexed by bots, probably indexing login form for just any url, so that's the annoying point (huge trolling possibilities, btw, there :) ).
I don't know about the most used stack, there are many ways to go depending on what you want to do, but I think the kitchensink approach of gigantic frameworks isn't commonly associated with Go, and I don't think Go really has one go-to stack like say Ruby on Rails. That does mean you'd have to be somewhat familiar with both Go and its community projects to make a decision.
I've just removed my previous version and then I realize there's no 1.8 on their website.
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.
If you're using Debian, or some similar system, chances are your package manager will never deploy something beneath /opt. So in my case I configure golang to install in /opt/golang/
On this particular host I have only three packages here:
$ ls /opt/
arduino-1.8.0
calibre
go-1.8https://talks.godoc.org/github.com/davecheney/go-1.8-release...
https://groups.google.com/forum/#!msg/golang-dev/Dn-pfWETUrM...
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.
From the HN guidelines: Please don't submit comments complaining that a submission is inappropriate for the site.
Very very slowly. Time spent fighting lacking programming languages also kind of kills people (steals time off of their lives).
And?
They're free to do so, if they think it can fit their needs.
Also, while Go isn't great, it isn't as terrible as some people make it. It mostly just isn't in any way exciting.
Which is why people need to be here every thread explaining the problems with Go.
You might be in the wrong business.
Even I that disagree with some of the decisions that were taken,see a value in having people using Go instead of C.
We detached this subthread from https://news.ycombinator.com/item?id=13662583 and marked it off-topic.
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.