http://tip.golang.org/pkg/sync/#Pool
There are a lot of cases where people write their own version of this (myself included, but also the connections in database/sql for example). It will be great to have an implementation in the standard library. This technique has been very, very useful in StatHat's production code as we have grown.
I understand your pain, but this is nowhere near a real issue for systems that Go is designed to help build.
I mean, in the thread that announces a new version of a language whose designers made it abundantly clear that it is intended to solve Google's problems, the top comment is about how to interpolate strings? I think they made a very good move by ignoring most syntax requests (There are a lot) and move on. Even better is their decision to harmonize formatting and build the formatter right into the language.
Syntax is extremely overrated, and evidence for it has been provided years ago. [1]
[1] http://c2.com/cgi/wiki?ProgrammingLanguagesAnInterpreterBase...
Edit: typos.
I spend most of my day designing and coding the sorts of systems which Go was designed to help build. I'll agree that this isn't a major issue, but it is affecting whether or not I actually enjoy using Go.
If you really want named variables in format strings you can make a template like "My name is {{.Name}} and surname is {{.Surname}}", and render the template with either a map of strings to strings, or a struct with the right named values.
"My name is #{name} and surname is #{surname}"
and this: "My name is " + name + " and surname is " + surname
or this: fmt.Println("My name is %s and surname is %s", name, surname)
Except the first one is much more readable.String interpolation seems like a small thing, but I find myself wanting to use it all the time. It's definitely not a "magic" feature. Javascript really needs it as well.
String interpolation is both practical and useful.
The intention of the programmer and the result is actually even more explicit than passing the values as arguments to some printf function.
As we slowly, oh so slowly, but surely move into languages where buffer overflows are not possible to write (or at least require scary excursions into some sort of "unsafe" package), easy string interpolations that allow the programmer to believe they don't have to think about the correct encoding of the value become the next most pressing security threat. Pretty much every "injection" is due to over-simplified string interpolation.
Unfortunately, if your string interpolation syntax is as easy is "This is an interpolated $string"... it's also wrong. Dead wrong, very wrong, run away screaming wrong wrong wrong! String interpolation is actually a very hard problem, and this must irreducibly manifest itself in the API. ImJasonH's example, while it isn't "string interpolation" in the Ruby/Perl/etc. sense, does involve using a template system with sensible escaping mechanisms... it's HTML-specific, though, but for HTML it's incredibly powerful and easy to use correctly. In fact Go's HTML templating is the most powerful and easy-to-use correct HTML templating system I've ever seen that isn't in Haskell. Presumably there are others out there, but I've seen a lot of the competition and most of them will sit by, twiddling their thumbs and whistling idly, while you put 100 injections of every kind into your HTML page.
My guess is Go will never grow this style of string interpolation, pretty much because it is so very, very frequently wrong. The way Go is already doing it is as easy as it can feasibly be, without encouraging wrongness.
Could I use it to allow developers to make plugins for a product in Go and C++ in a secure way, instead of using say Lua?
I'm open to suggestions.
s := make(map[string]struct{})
s["foo"] = struct{}{}
if _, ok := s["foo"]; ok {
// exists
}
There are varying amounts of fluff you can put on top of this, but that's the basic approach. Wrap it up in a type with methods if you're using it a lot in a program.Perhaps you also want built-in union, intersection, difference, etc. I personally find I need a set with simple membership testing about 10x as often as I need more advanced set operations, so from my perspective it's fine to leave those to third-party libraries.
If you are at GopherCon, I'll be giving a lightning talk on Saturday 11:40am on things I've learned by contributing to fsnotify and other open source projects. Happy to chat more about fsnotify afterwards.
We're still figuring out what os/fsnotify will look like.
https://github.com/pkulak/simpletransport
It sure would be nice to reuse connections without memory blowing up!
I personally prefer vim, and use the vim support delivered with Go plus gocode for code completion, that's really all I need for development. Unlike with Java, I never felt the need for an IDE with Go.
1. Quickly run/restart your application 2. Run specific unit test (all in package, all in file or specific one) 3. Parameter and func signatures are more detailed via CTRL+P (parameter info) than what you would get with GoSublime and GoCode.
There's only one thing so far I found a bit quirky:
Say you got a function with the signature func() (err error) and pass it as a parameter to another function that has the signature func F(f func() error), it will complain that the signatures don't match, but it will still compile.
http://dominik.honnef.co/posts/2013/03/writing_go_in_emacs/
http://dominik.honnef.co/posts/2013/08/writing_go_in_emacs__...
Not so much an IDE, dependent on your definition. More of a set of editor extensions, but useful so far.
Of course IDE availability should be low on the list of selection criteria for any language...
gccgo is also supposed to produce better code for certain computationally heavy workloads.
Unfortunately, this is very seldom true. Gccgo could potentially generate faster floating point code, but its lack of escape analysis grinds it to a halt.
http://dave.cheney.net/2013/11/19/benchmarking-go-1-2rc5-vs-...
https://groups.google.com/forum/#!topic/golang-dev/2YRmu_AWz...
If you have one version where you have a good grasp of how it compares to C++, that should provide an answer, right?
contains no language changesNot the best example to justify adding generics late.
I'm all of the day generics is finely added (and yes I missed it a lot when I was new to Go a couple years ago), but it is much less of a issue then some people make it out to be.