← Back to Blog | Learning Go for Typescript developers

| Talor Anderson

I recently started a new position where most of my work is in Go.

I've spent almost my entire professional career writing Typescript code, and needed to get up to speed quick at my new job. With a few resources, I was able to jump in and start making contributions to our codebase almost immediately.

Go is designed for simplicity, and it shows. Skimming Go code often feels like reading pseudocode: nothing is hidden or overly abstract.

Lots of things transfer over quickly from Typescript to Go. AI helps a lot here: It's still hard for me to write Go from memory, but I can usually look at some AI generated code I created and tell if it's correct or not. And selecting some code blocks and asking, "what does this do?" is usually very effective. This is really the first language I've tried to learn since AI became "a thing", and it makes such a difference!

However, as I got deeper into the language, I started finding more and more bits of syntax and conventions that just didn't make sense to me, or felt like I didn't know the "right way" to do something.

For example, one surprise to me was that almost everything in Go runs synchronously. Typescript relies heavily on async/await, and I was surprised not to see a similar keyword in most of our Go code. I quickly realized these languages might not be as similar as I first imagined.

I've had to go back to square one and find some resources to get a better understanding of Go as a whole, coming from knowing Typescript very well. I imagine this transition path is going to become more and more common - especially with the new Typescript compiler being written in Go.

Here are some resources that have been most helpful for me as I learn Go as a Typescript developer:

Go by Example

Go by Example is just what it sounds like: an organized-ish list of everything you can do in Go. It covers everything from the simplest Hello World program to HTTP servers and performance benchmarking.

I have found this site most helpful to get familiar with pieces of the language that don't have neat analogues in Typescript, showing the shape of what's possible in the language. (example: channels)

My only critique of this site is that its examples are incredibly terse. They demonstrate what the syntax looks like, but don't go into exhaustive examples or use much description at all.

Go by Example is great for knowing what's possible in the language, but you might have trouble actually applying the concepts it teaches without doing more research on your own.

100 Go Mistakes

100 Go Mistakes is both a book and a website that helps teach more subtle concepts of the language: What should you not be doing in Go?

I've found this site extremely helpful for documenting conventions and tips that aren't obvious when you're reading existing Go code, but are pitfalls you're likely to stumble into by writing Go as a beginner.

I don't have the book yet: I don't know if it has more explanations than the site version, but it might be helpful just to have this as a desk reference either way.

Practical Go

Practical Go by Dave Cheney has some great real-world examples on how to use Go: for example, how to set up a package with good naming conventions.

These explanations are longer than the ones provided at either 100 Go Mistakes or Go By Example, and cover more in-depth topics, so it's a great resource to skim once you're familiar with the first two.

Conclusion

Go is a language all its own, with cool features, quirks, and pitfalls you should be aware of if you're spending much time writing it.

Coming to Go from Typescript was a really enjoyable experience. I never needed to pick up a book of syntax. The above resources, plus working with AI, got me very far along in working in the language.

While I like working in Go, I still think I'm a Typescript developer at heart. Maybe that will change someday.

Leave a comment on Bluesky

Comments

Loading comments...