This week's book giveaway is in the Python forum.
We're giving away four copies of Hello World and have Warren & Carter Sande on-line!
See this thread for details.
Win a copy of Hello World this week in the Python forum!

Matt Farina

Author
+ Follow
since Sep 15, 2016
Cows and Likes
Cows
Total received
5
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Matt Farina

The standard library is full of useful packages. When you get outside of these there are just so many good ones. A few I've used:
  • gopkg.in/yaml.v2 - for parsing and writing YAML
  • github.com/urfave/cli - for creating CLI applications
  • google.golang.org/grpc - gRPC has some nice features
  • github.com/golang/protobuf - protocol buffers


  • If anyone else has ones they'd list I'd be curious to see them.
    3 years ago
    Go
    On Gotcha that I had to learn early on is that the application exits when main finishes. Even when there are concurrent goroutines doing work you intend. To avoid that there are ways to make sure main waits for the other work to finish before exiting.

    Because of the way Go handles concurrency that can run on multiple threads this seemed like a fairly unique one to Go. We do cover waiting in Go in Practice.

    This was one I had to learn the hard way.
    3 years ago
    Go
    Go in a C based language. I found it to be similar to learn to them. The unique place, such as concurrency and package handling, are the areas that will take more to learn.

    One of Go's strengths is the ability to leverage multi-core processors and to do work concurrently and in parallel. Learning these new pieces, that only make sense given fairly modern hardware, is where learning tends to be.
    3 years ago
    Go
    As I've been told, Go can be learned in a week or two. Go tries to have one common way to do things. This is called idiomatic Go. Because of this it can be a quick language to learn.
    3 years ago
    Go
    This is a good question and something I talked about in Chapter 1 (free download) of Go in Practice. Here is a short list:

  • Cloud platforms - for example, Kubernetes and Cloud Foundry
  • Microservices - for example, look at CoreOS etcd or Hanshicorp Vault
  • Web services - for example, dl.google.com
  • CLI tools - for examples see Hugo the static site generator
  • Databases - for example, InfluxDB and CockroachDB
  • Applications - for example, the Caddy webserver


  • You'll notice it's good at cloud services and lots of applications. Go isn't great at mobile (but it's improving) or desktop applications.

    Does that help?
    3 years ago
    Go
    There are a couple different routes you can take to writing a web application. If you want to look at the standard library you can checkout the article in the Go docs on web development. If you like frameworks that help you checkout revel.

    The go compiler also contains a toolchain for documentation, testing, and other features. If you need something to help with package management I would suggest Glide.

    Does that help?
    3 years ago
    Go
    First, I'm no expert in garbage collection systems.

    The garbage collection system in Go is a moving target. With each new release it gets better. It used to be slower and sometimes noticeable. The performance of the GC has been an area of focus for a couple years and that focus has lead to improvements.

    Go used to use a stop-the-world GC. As of Go 1.5 the GC is able to do much of its work in parallel. If you want to read about it you can start here. Yet, since this point the GC has continued to see improvements. In particular to the amount of time the GC pauses take which keep shrinking.

    From a practical perspective, garbage collection in Go isn't something you notice most of the time.

    Unfortunately, I don't know enough about how the Java GC works to do a comparison.
    3 years ago
    Go
    Note, Chapter 3 from Go in Practice talks about concurrency. It's a free download (warning: pdf).

    The Go model for concurrency is heavily inspired by CSP. In Go, the runtime manages a number of threads. Typically this is ~1 per core but it is configurable if you want to change it. Concurrency is via goroutines, which are concurrent functions that are scheduled and run on those threads. They are sometimes called lightweight threads. They are lightweight as far as footprint but are not technically threads.

    To start of a goroutine you simple use the go keyword. For example:


    The Go runtime schedules goroutines. It's not unusual for thousands or more goroutines to be going at the same time or to have had millions of them over the life of a running application.

    The functions can also be closures and be run as goroutines.

    Communication happens through channels that pass instances and other variables between goroutines.

    Some of this is also covered in chapter 1 which is a free download. There are even pictures.

    Conceptually, it reminds me of JavaScript but there is the ability to communicate between concurrent functions and the runtime is multithreaded.

    I'll let you decide if it's easy.
    3 years ago
    Go
    Here are a few free resources that might be useful:

  • Go for Java Developer slides from presentation
  • Tour of Go (interactive tutorial)
  • An Introduction to Programming in Go (free book)
  • 3 years ago
    Go
    If you're developing mobile apps in android than Java is likely the right language for you. Even though Go is starting to get into that space.

    I'll try to give you one compelling reason to consider Go. Numerous folks have rewritten applications from Java to Go. In doing so the new applications have a radically reduced resource footprint. AeroFS is one example, that comes to mind, where they published some details. You can read about it on their blog.

    Here's a little teaser quote...

  • Resident memory usage dropped from 87MB down to a mere 3MB, a 29x reduction!
  • The resulting docker image shrunk from 668MB to 4.3MB, a 155x reduction!


  • Go applications tend to be high performance while using less resources than the comparable Java apps.

    Is that interesting enough to give it a look?
    3 years ago
    Go
    The Go toolchain, which includes the compiler, also includes testing and reporting tools. Testing is a first class citizen.

    Test files are those that end in _test.go. Files with this ending are skipped when building but included when running the test suite. Test files live alongside application source files.

    Tests use the testing package from the standard library. Tests start with Test. For example...



    Normal language functionality is used in the tests. In addition to tests like this there are benchmarks, example, and more.

    Then there are feature like the code coverage reports. You can read about them in this blog post. This has now been moved into the toolchain and requires no additional feature be installed. There coverage reports can be viewed in HTML or exported to other services like https://coveralls.io/.

    It's really common to integrate Go into testing systems. For example, Travis CI has Go support as a first class language. If you have Go installed on a Jenkins server you can test with it. Or, if you want to test against multiple versions you can even use the Docker plugin for Jenkins and use differing versions of the golang image as a base.

    Does this help?
    3 years ago
    Go
    I'm happy to chime in with my 2 cents.

    - Where can you deploy a Web App built in Go?



    You can deploy web apps built in Go in the usual places. Heroku, Cloud Foundry, OpenShift, AWS, or any number of other places. For example, Heroku has a buildpack just for Go.

    Go builds a binary and that binary can be deployed almost anywhere, without the need for a runtime, and can run there. Go applications, which include all libraries in a single library, can be built for varying architectures and operating systems. The Go compiler can cross compile out of the box.

    Go is now in the top 20 for TIOBE. Because of that popularity there is now fairly wide support.

    - Currently, which are the most common use cases of Go in the real life development?



    Here are few common ones...
  • Infrastructure platforms. For example, Docker, Kubernetes, and Cloud Foundry
  • Microservices. For example, Etcd and Vault
  • Web services. For example, dl.google.com
  • Applications. For example, Hugo the static site generator, and Caddy, the web server


  • There are many others.

    Hope this helps.
    3 years ago
    Go
    Thanks for asking a softball question!

    For anyone not familiar, Generics is a common discussion point for those looking at Go. So much so, there is an entry in the FAQ about it.

    Generics may well be added at some point. We don't feel an urgency for them, although we understand some programmers do.

    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.

    The topic remains open. For a look at several previous unsuccessful attempts to design a good generics solution for Go, see this proposal.



    The typical solution for handling this in Go is using interfaces. Some folks have written about it such as the post here and here.

    In my personal experience I've been able to use interfaces and a small amount of copy-and-paste to work around the lack of generics.

    Is there something more specific you're curious about?
    3 years ago
    Go
    Go was created solve some of the practical problems they had with language at Google. If you're looking into an overview of Go with some details about what's interesting about the language you can checkout Chapter 1 of Go in Practice (warning, PDF). It's a free download.
    3 years ago
    Go