11 ms·
Go 1.2
- Nican 13y agoChanges can be found here: http://tip.golang.org/doc/go1.2 http://tip.golang.org/doc/go1.2
- mseepgood 13y agoBuilt-in test coverage, nice.
- humanfromearth 13y agoI was wondering when we'll get three-index slices
- wreegab 13y agoFrom the text: "It is impossible to use this new slice value to access the last three elements of the original array" Shouldn't this rather be: "It is impossible to use this new slice value to access the last element of the original array"
- Jayschwa 13y agoIt looks like the third number specifies an index, not a length. var array [10]int slice = array[2:4:7] > its capacity is now only 5 elements (7-2)
- deleted 13y ago[deleted]
- kitsune_ 13y agoNice, congratulations on the release. I'd really like to see some progress on generics / parametric types. I'm starting to get the impression that it will never happen.
- praptak 13y agoIt looks like 1) generics are not very well aligned with the main design goals of Go and 2) it would take a very well thought out design to align them so, if that's possible at all. From the FAQ: "Generics are convenient but they come at a cost in complexity in the type system and run-time. We haven't yet found a design that gives value proportionate to the complexity, although we continue to think about it. Meanwhile, Go's built-in maps and slices, plus the ability to use the empty interface to construct containers (with explicit unboxing) mean in many cases it is possible to write code that does what generics would enable, if less smoothly. This remains an open issue."
- lloeki 13y ago> the ability to use the empty interface to construct containers (with explicit unboxing) I'm not versed in Go, but does that mean something similar to (Java-style) Object[] and explicit casting of each value you get out of the list?
- kitsune_ 13y agoGo has so called type assertions, an example: http://play.golang.org/p/L5hprjhqN_ http://play.golang.org/p/L5hprjhqN_ In this example, one function probes the underlying type by using t.(type), and the other one uses a type assertion by doing a val, ok := t.(int) - The type assertion will return the value of the integer and true if t happens to be an integer (a Go function can return multiple values) If you pass an object as an "empty interface{}" you can test the underlying type. edit: Note that you can only use a type assertion with an interface! So, this fails: http://play.golang.org/p/0BtSWfE3f2 http://play.golang.org/p/0BtSWfE3f2 but this doesn't: http://play.golang.org/p/tZB4Jivp3z http://play.golang.org/p/tZB4Jivp3z
- lloeki 13y agoIs this purely evaluated at runtime or does Go annotates types with its static analysis and restricts the interface in some ways? IOW are default and else cases made optional by Go's static analysis, which would help Go throw its arms up at compile time if an unexpected type is passed?
- buro9 13y agoIf you're used to running from source using this: hg pull hg update release It does not yet return 1.2. You'll need to use: hg pull hg update release-branch.go1.2 And then build. The OP link goes to the commit showing this branch being finalised.
- rsc 13y agoYes, the release has not happened yet. That commit is just the penultimate step.
- jawr 13y agoThis release is out on 1/12/13 it's still meant to have a major bug. This isn't actually a release...
- buro9 13y agoThis is definitely the wrong place for it... but I noticed with the vet and godoc move that I had trouble "go get"ting them. I have GOROOT in /usr/local/src/go and root owns that as it's put there in our dev builds by our bootstraps scripts. I have GOPATH in /home/{user}/Dev/Go One cannot go get as root from GOROOT for system install, and one cannot trivially go get in the user GOPATH either. The latter is due to vet and godoc needing permission against GOROOT. If you sudo the go get within GOPATH, then that works from the GOROOT permissions point of view, but then (once you get past Mercurial freaking) the bits of GOPATH/pkg and GOPATH/src that relate to vet and godoc and owned by root... making any subsequent go get of say, the HTML parser, fail because it cannot write to the folder. I ended up doing this as a user to go get vet and godoc within GOPATH: echo "[trusted] users = * groups = * " > ~/.hgrc sudo sh -c "export GOPATH=$GOPATH && export GOROOT=$GOROOT && export PATH=$PATH:$GOROOT/bin && go get -u code.google.com/p/go.tools/cmd/godoc" sudo sh -c "export GOPATH=$GOPATH && export GOROOT=$GOROOT && export PATH=$PATH:$GOROOT/bin && go get -u code.google.com/p/go.tools/cmd/vet" USER=$(whoami) GROUP=$(id -g -n $USER) sudo chown -R $USER:$GROUP $GOPATH It works, but there is a better way, right? Do the docs assume Go source installs are user specific?
- friendly_chap 13y agoI am a heavy user of Go, I use it in my job and for side projects as well, for years now. The lack of generics in Go takes away most of the fun from coding after a couple of month. Despite what is being said, interfaces do not lessen the pain. With a better type system, taking ides from Haskell (ADT, generics done well, ability to implement interfaces for a type outside of its package etc) Go could be the perfect "dirty Haskell" for me, but now it is just a meh language with a half assed implementation. That being said, it is still a much better choice then a lot of overcomplicated languages out there. EDIT: The biggest practical problem with not having generics is the fact you do not have access to list (slice in Go) manipulation functions. This means you have to implement them yourself, on the fly, for the given type when you need it. This does increase the time it takes to implement something, but also can introduce a lot of bugs as well - you can't rely on (almost guaranteedly) bug free implementations of existing functions. Of course this runs much deeper than just the list type, but on day-to-day basis I feel this to be the biggest pain. But the rabbit hole is deep: we could get into how the multiple returns values are just a really inconvenient (not composable) workaround of not having a generic tuple type...
- latch 13y agoAlso have large Go systems in production, and I agree lack of generics is a problem. The biggest problem for me though, is the lack of testability. As a simple example, the fact that log.Logger isn't an interface means everyone creates a wrapper just for testing purposes. DI is also complicated enough that in some cases, it's just easier to forget about unit tests and stick with integration tests.
- jerf 13y agoThat is a problem that interfaces can solve. I agree it's a bizarre oversight that the logging package doesn't define an interface, but it's also one very easily corrected, and since interfaces are implicitly fulfilled, the standard logger trivially meets the interface you define. We've found there's a few other places in the core libraries we expect an interface and there isn't one, but, again, fortunately it is trivially fixable. I'm actually finding Go to be one of the testable imperative languages I've used. This isn't everything I've developed for it, but this is one of the fundamental tricks: http://www.jerf.org/iri/post/2923 http://www.jerf.org/iri/post/2923 Also remember that global variables are still Bad. If you've got a global Logger, you've already lost. Fortunately, struct embedding seriously mitigates the pain of passing things around and using them. While this will probably break apart into multiple objects as I continue developing, I've taken to having this sort of structure: type Services struct { *logging.logger // actually our custom logging package database.Database // locally defined interface connections.Tracker // registers connections or whatever } I then have my primary objects embed a Services instance, so logging is just "obj.Error(...)". I pair that with a function that can construction a "null" Services, with a logger that doesn't log, a connection registration system that doesn't register, etc. Combined with what I linked, this enables even rather complicated interactions to be feasibly tested in relative isolation. I've also created some basic mock objects for some of the objects that may for instance assert that the Logger is called when expected, etc. Technically none of this is impossible in other imperative OO languages, but Go has just enough twists on things to make it qualitatively easier, mostly implicit satisfaction of interfaces, which has had consequences beyond what I've expected. Embedding has had surprisingly pleasant consequences too; complicated objects can be safely built up with rich interfaces that do not require you to hardwire them together, or give you excessive access to the internals of the bits.
- tomaszkubacki 13y agoI think Go is a beautiful language but at the same time I'm sad when I realize it will never become mainstream since: a) lack of AAA IDE (like Visual Studio) - people are just too lazy b) most of dark matter devs are used to OO langs
- matiasb 13y agoAny Go jobs over there?
- jbk 13y agoI do offer Go jobs. But in Paris, France :)
- catwell 13y agoInteresting. Are you using Go in VLC? If so, where?
- thibaut_barrere 13y agoDo you have a contact email? Not for me but maybe some of my twitter followers could be interested. Thanks!
- jbk 13y agoMy email should be easy to find :) jb@ videolan.org
- zura 13y agoAny C++ jobs? :)
- 13y ago
- dbaupp 13y ago> The scheduler is invoked occasionally upon entry to a function [from http://tip.golang.org/doc/go1.2 http://tip.golang.org/doc/go1.2] Does this mean that every function call has to do a check and possibly an (atomic?) increment of some variable?
- riobard 13y agoPeople using lots of goroutines should note the change of minimal stack from 4KB to 8KB. “Updating: The increased minimum stack size may cause programs with many goroutines to use more memory. There is no workaround, but plans for future releases include new stack management technology that should address the problem better.” This is a runtime/debug call to restrict the max size of stack. Somehow I feel like there should be one to set the min size too…
- jawr 13y agoNot an actual release, the VERSION file changed on a non-main branch.. Stop jumping the gun.
- booop 13y agoHas anyone combined Go and angular.js to build something? How were your results?
- kisielk 13y agoYes, though for an internal project so I can't share it here. Go is pretty well suited for building REST APIs and combines quite easily with a front-end JS app built in Angular.
- rdtsc 13y agoThe two are rather separate. The only way I can see combining them is if there is extensive server side template-ing. But angular.js kind of discourages that. So you can use go to build a RESTful server and then use angular.js on the front end. But that sort of de-couples the system to the point where it doesn't make sense to talk about an advantage of a combination of both.
- mjibson 13y agoHaving myself written such a site (http://www.goread.io/ http://www.goread.io/), I concur. Having go on the backend didn't provide any benefits with an angular frontend over another language. I just think they excel at their respective purposes - that's why I chose them.
- reneky 13y agohttps://www.goread.io/ https://www.goread.io/ combines a Go backend and angular.js frontend.
- _ak 13y agoI do a (currently not yet launched) project with Go on the backend and AngularJS on the frontend, and it's just... really simple and obvious.
- bct 13y agotomaszkubacki: You have been hellbanned.
- AYBABTME 13y agoGo 1.2 is not yet released.
- cpeterso 13y agoAre there any plans to self-host the Go compiler in Go itself? Rust is self-hosted in Rust (originally bootstrapped by a Rust compiler written in OCaml). I've found a couple Go compilers written in Go that bind to LLVM backends, but they are just prototypes. The Go developers make a big deal about compilation speed. Wouldn't Go's goroutines have some interesting possibilities for parallelizing compilation?
- BarkMore 13y agoSelf hosting is mentioned in the FAQ: http://golang.org/doc/faq#What_compiler_technology_is_used_to_build_the_compilers http://golang.org/doc/faq#What_compiler_technology_is_used_t...
- justinhj 13y agoHere's a long quote by Rob Pike, which whether you agree with the points he makes or not, explains why Go does not have generics. "Early in the rollout of Go I was told by someone that he could not imagine working in a language without generic types. As I have reported elsewhere, I found that an odd remark. To be fair he was probably saying in his own way that he really liked what the STL does for him in C++. For the purpose of argument, though, let's take his claim at face value. What it says is that he finds writing containers like lists of ints and maps of strings an unbearable burden. I find that an odd claim. I spend very little of my programming time struggling with those issues, even in languages without generic types. But more important, what it says is that types are the way to lift that burden. Types. Not polymorphic functions or language primitives or helpers of other kinds, but types. That's the detail that sticks with me. Programmers who come to Go from C++ and Java miss the idea of programming with types, particularly inheritance and subclassing and all that. Perhaps I'm a philistine about types but I've never found that model particularly expressive. My late friend Alain Fournier once told me that he considered the lowest form of academic work to be taxonomy. And you know what? Type hierarchies are just taxonomy. You need to decide what piece goes in what box, every type's parent, whether A inherits from B or B from A. Is a sortable array an array that sorts or a sorter represented by an array? If you believe that types address all design issues you must make that decision. I believe that's a preposterous way to think about programming. What matters isn't the ancestor relations between things but what they can do for you."
- kung-fu-master 13y agoFrom this message I understood that the Go is a language only for him and not for others developers.
- axaxs 13y agoYou're right, kinda. It's been obvious from the start that this is a bell labs venture so to speak. I love the language, and assume the likes of Pike, Thompson, and Cox to know enough to know better. Community driven languages suck, so I leave it to those much more experienced than me to make these decisions, and I'm ok with that.
- 13y ago