News for hackers. Stuff that matters.
Re:Why Go Is An Excellent Modern Programming Language by thirsteh on Sunday July 28, 2013 @03:47PM (#6117820)
Weird. I had the exact opposite experience. Extremely easy to pick up, especially if you are familiar with both C and Python, since Python lists are fairly similar to slices.

Also, the documentation is far better than e.g. that for Java and C#: http://golang.org/pkg/io/ / http://golang.org/pkg/io/ioutil

Reading a file into memory is as simple as:

    data, err := ioutil.ReadFile("filename")
Re:Why Go Is An Excellent Modern Programming Language by ancarda on Sunday July 28, 2013 @05:08PM (#6118105)
I can side with OP, I find the documentation very disappointing. After several days, I eventually gave up trying to append to a log file in Go. I just couldn't figure it out. I also read a book on Go but it only covered reading files.
Re:Why Go Is An Excellent Modern Programming Language by mayanksinghal on Sunday July 28, 2013 @06:53PM (#6118435)
It seems like http://golang.org/pkg/os/#pkg-constants has O_APPEND and searching for 'Append file Golang' gives http://stackoverflow.com/questions/13513375/how-to-append-te... fairly on top.
Re:Why Go Is An Excellent Modern Programming Language by ancarda on Sunday July 28, 2013 @07:58PM (#6118624)
I got that, but actually writing to the file? What I'm looking for is something like this: http://msdn.microsoft.com/en-us/library/ms143375.aspx

It covers everything you need to know. The MOST important part being "example". I don't see any on Go's documentation. That just led me to being frustrated. Also, I actually only see a list of functions and a very short, vague description.

Re:Why Go Is An Excellent Modern Programming Language by amatsukawa on Monday July 29, 2013 @03:21AM (#6119761)
I don't really know Go except for like 5 min of reading up on its syntax, so I could be wrong, but this assertion that it was not obvious how to write to a file in the documentation surprised me. So I clicked on the stackoverflow link.

OpenFile returns type File from the signature. http://golang.org/pkg/os/#OpenFile

Scanning through the methods (or doing a cmd + f search for "disk") has this method http://golang.org/pkg/os/#File.Sync

Method description says "Sync commits the current contents of the file to stable storage. Typically, this means flushing the file system's in-memory copy of recently written data to disk." Isn't that what you want?

Was it as clear as the C# example? Probably not. But I don't think this was terribly hard to find. Code examples will come in time, as the language matures.

IMO whether to put code examples into the documentation is really a choice by the language maintainers. Lots of code examples can also clutter the docs. I prefer to just have the docs tell me what each function does. If I really get confused, I can google for examples. Java also doesn't really have code examples right in the documentation, but they aren't hard to find because it's been around for a long time. For example, Googling for "java code example how to append to a file" and click on the first link.

Re:Why Go Is An Excellent Modern Programming Language by thirsteh on Monday July 29, 2013 @03:56AM (#6119846)
Okay, it might not be totally obvious, but File implements io.Reader and io.Writer (you can tell by the Read and Write methods.) Therefore, you can use all the functions that take an io.Reader or io.Writer, i.e. all the functions in http://golang.org/pkg/io/ and http://golang.org/pkg/io/ioutil/. It also implements io.Closer (Close() method), which you can use to flush and close the file when you're done.

It would probably be helpful if there was some kind of auto-generated list of the known (or at least stdlib) interfaces a given type implements, even if you don't actively declare it (like Java 'implements'.)

Re:Why Go Is An Excellent Modern Programming Language by tracker1 on Sunday July 28, 2013 @06:06PM (#6118261)
I was going through the learn go lessons from the main website, and when I got to the portion about creating a custom image interface, found it very difficult to piece together a working example.. I finally got that frame done, but when I had finished it took so long that I had to do something else and have yet to get back to it.

It was pretty interesting, and I find a few bits were harder to deal with than others (such as {} being required for conditionals, even when on the same line) in terms of my own habits. The language wasn't particularly difficult, but when I got to a few of the higher lessons/challenges, getting the answer took more time than I thought it should, or would with any other language for similar problems.

Searching for go examples is worse than when C# first started out.. searching "golang" yields slightly better results, but still not the easiest thing to search for examples with/on.

Re:Why Go Is An Excellent Modern Programming Language by mattmanser on Sunday July 28, 2013 @03:57PM (#6117861)
In what crazy world is that documentation better than C#?

There are no examples, the lifeblood of documentation, nor any notes about gotchas?

It's early days in the language so that's not at all bad, but claiming the documentation is better when it's clearly not is odd.

http://msdn.microsoft.com/en-us/library/b9skfh7s.aspx

Also C# and java are going to have tons of examples on SO, so the amount of examples and extra documentation available is incomparable.

Re:Why Go Is An Excellent Modern Programming Language by thirsteh on Sunday July 28, 2013 @04:05PM (#6117893)
There are many examples in the Go docs, e.g. http://golang.org/pkg/net/http/#pkg-examples (runnable and editable too!) But I agree that there aren't enough, and that's probably the worst thing about Go documentation, especially when dealing with the lower-level libraries.

Just to be clear, I don't think verbosity means that documentation is better. Documentation is better when it gives you the information you need, and nothing more. That being said, I mostly think Go's documentation is better than Java's, and on par if not slightly better than C#'s. Here's a better example of what I mean, e.g. http://docs.oracle.com/javase/6/docs/api/allclasses-noframe.... vs. http://golang.org/pkg/

Granted, if you have no experience at all with the language--e.g. you haven't even taken the tour at http://tour.golang.org/--the documentation may be hard to read (what does "[]" mean, for example), but that's not the fault of API documentation, which rightly is clear and concise. Rather, that's the job for a comprehensive tutorial, which Go has: http://tour.golang.org/

Re:Why Go Is An Excellent Modern Programming Language by acqq on Sunday July 28, 2013 @04:18PM (#6117936)
Is this a joke about many examples? The example you link to at the current moment looks like this in two different browsers:

http://i40.tinypic.com/5vorps.png

Re:Why Go Is An Excellent Modern Programming Language by thirsteh on Sunday July 28, 2013 @04:26PM (#6117968)
I changed that a couple of minutes after posting. I just messed up the link.
Re:Why Go Is An Excellent Modern Programming Language by acqq on Sunday July 28, 2013 @05:48PM (#6118211)
I see you now link to completely another example. But the example of the listener you linked first, that is, at the time I've made a comment still just contains

http://golang.org/pkg/net/#example_Listener

   ---- begin example ---
   package main
   ---- end example ---
which is a good example of a nonexistence of one good example.
Re:Why Go Is An Excellent Modern Programming Language by thirsteh on Sunday July 28, 2013 @06:19PM (#6118324)
Like I said, I changed the link two minutes after I posted the comment (way before you posted yours, but whatever) because I messed up the link. You can find the listener example here: http://golang.org/pkg/net/#pkg-examples
Re:Why Go Is An Excellent Modern Programming Language by _random_ on Sunday July 28, 2013 @04:22PM (#6117955)
Dude, you are ignorant about the level of C# documentation.
Re:Why Go Is An Excellent Modern Programming Language by thirsteh on Sunday July 28, 2013 @04:26PM (#6117970)
Dude, I don't think I am.