4 ms·
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 simi
by thirsteh 13y ago
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/ / http://golang.org/pkg/io/ioutil http://golang.org/pkg/io/ioutil
Reading a file into memory is as simple as:
data, err := ioutil.ReadFile("filename")
- mattmanser 13y agoIn 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 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.
- thirsteh 13y agoThere are many examples in the Go docs, e.g. http://golang.org/pkg/net/http/#pkg-examples 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.html http://docs.oracle.com/javase/6/docs/api/allclasses-noframe.... vs. http://golang.org/pkg/ 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 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/ http://tour.golang.org/
- acqq 13y agoIs 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 http://i40.tinypic.com/5vorps.png
- thirsteh 13y agoI changed that a couple of minutes after posting. I just messed up the link.
- acqq 13y agoI 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 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.
- thirsteh 13y agoLike 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 http://golang.org/pkg/net/#pkg-examples
- _random_ 13y agoDude, you are ignorant about the level of C# documentation.
- thirsteh 13y agoDude, I don't think I am.
- deleted 13y ago[deleted]
- ancarda 13y agoI 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.
- mayanksinghal 13y agoIt seems like http://golang.org/pkg/os/#pkg-constants 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-text-to-a-file-in-golang http://stackoverflow.com/questions/13513375/how-to-append-te... fairly on top.
- ancarda 13y agoI 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 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.
- amatsukawa 13y agoI 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 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 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.
- tracker1 13y agoI 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.
- deleted 13y ago[deleted]