Struggling to Find the Right Use Cases for Go Looking for Insights from Other Devs

As a developer with extensive experience in PHP over the years, as well as Python and other web technologies like HTML, JavaScript, and CSS, I’ve found Go to be an incredibly fascinating language compared to Kotlin/Java, C# and Node.JS (for example: small external dependencies for most use cases, cross platform compiling, concurrency). However, I’m still struggling to find practical use cases where Go truly shines for my needs.

When it comes to web backend development, PHP has been my go-to language for a long time. Not only does it power some of the largest CMS systems, but PHP has come a long way with the improvements in version 7 and especially 8.3, introducing features like the Just-in-Time compiler. Additionally, PHP is widely supported by most web hosts, making it extremely easy to integrate. Whether it’s running on shared web hosting, a VPS, or a dedicated cloud infrastructure, PHP scales dynamically, covering both small and large-scale use cases with ease. In contrast, deploying a Go-based web application often requires more advanced access to a server or at least a system where you have control over the runtime environment. A simple PHP script can often run on basic webspace, while Go needs a more tailored setup.

That’s not to say I haven’t tried to use Go in different scenarios. I recently attempted to develop a desktop application with Go to extract text from PDF files, process the data using AI, and classify it. However, I encountered significant challenges with Go’s ability to extract text from PDFs. Despite testing nearly all available libraries (for example GitHub - dslipak/pdf: PDF reader and GitHub - ledongthuc/pdf: PDF reader), none could handle the variety of PDFs I was working with. In the end, I had to rely on integrating an Apache Tika Java application with Go, which added unnecessary complexity, including a larger file size and the requirement to have Java installed on the system. While this solution worked, I would have preferred a more straightforward, pure-Go approach.

On a positive note, building the desktop UI with Go’s Fyne framework was relatively smooth and practical, so there’s definitely potential there. However, my original goal of building a fully functional desktop application with Go and local file processing (data privacy for end users and so I can deliver this program for free to end user) wasn’t as seamless as I had hoped.

Another area where I found Go less practical is working with JSON structures. With PHP and JavaScript, handling JSON data—especially when the structure isn’t always 100% predictable, such as when working with API responses—feels much easier. Both languages are highly flexible when dealing with dynamic or partially defined structures. In comparison, working with JSON in Go feels a bit more rigid and cumbersome, particularly when the API responses don’t always perfectly match your predefined structures. I also noticed that when OpenAI introduced the new structured JSON format, the Python library implemented support for it several weeks before the Go libraries caught up. This highlights how, in some cases, Go’s ecosystem can lag behind more established languages like Python or JavaScript.

When it comes to system administration tasks, I usually opt for Python or shell scripts. The reason is simple: Python scripts typically come with most of the functionality I need baked in, without requiring additional project files or complex setups. You just write the script, run it, and it works. Plus, Python is easy to edit and doesn’t require compilation, which is perfect for tasks like log file analysis, updating staging systems and so one. Here, Go’s compiled nature doesn’t feel as natural. I’d rather have a simple, editable script that doesn’t need multiple files or a complex build process. Go, while powerful, doesn’t offer that same level of simplicity for these quick, iterative tasks.

So far, I’ve explored Go in web backends, desktop applications, and sysadmin scripting, but I haven’t found a case where Go has stood out as the superior choice. Whether it’s due to the immaturity of certain libraries or the language’s paradigm not aligning well with certain tasks, I keep encountering limitations. Despite my excitement to use Go more, I often find that PHP or Python end up being the more practical choice for most of my projects.

That brings me to my question: for those of you who use Go, what kinds of applications are you primarily building? If your use cases overlap with mine, I’d love to know why you chose Go over PHP or Python. Your insights could really help me figure out where Go fits best in my workflow and which projects might benefit from it.

Thanks for sharing your thoughts!

Size, dependencies, speed. Short it is cheaper in every aspect. You can build a web site just as one single executable by using //embed.

Although Go not is used basically for web development, I find the Go HTML templates was very easy to create my first web site. Although I should have done it differently today.

And I have created some API and Cron servers where Go is more targeted for.

I’ve tried using go, desktop apps, web services, network forwarding, monitoring services, mobile apps (hybrid), OpenGL (2D), Pi4B development, and more
I think I can make a few comments.

  1. Desktop app
    Very bad, there is no too good solution at the moment, fyne I have used and written applications, but the destructive API interface and strange memory scheduling make me dislike this development framework, even though it is currently the best GUI framework for pure go.
    I’ve also used wails, but it’s still missing some GUI features, such as not being able to multi-window.
  2. Web Services/Networks
    To put it simply, there are so many success stories of GO in this regard, and if you question it, I don’t think you have reached deep enough.
    In the beginning, Golang also had a huge advantage in terms of networking (Goroutine, Web Library, CGO, etc.), which made the language stand out, and its efficiency is unquestionable at present.
  3. Tool library support
    Because of the success stories and the proportion of practitioners, Golang’s non-network toolbase is relatively weak, but there is nothing to do.
    I’ve also encountered support for PDFs, and it’s flawed because most people don’t pay attention to this part.
  4. C language
    One of the big advantages of Golang is that it’s very close to the C language, which is relatively easy when you need to reference some C libraries.
    And for similar reasons, there are many c bind libraries, and you can often write the corresponding go code by looking at the c documentation, such as OpenGL, Qt, VLC, etc.
  5. Embedded
    It is undeniable that it is indeed useful to write embedded projects, but it is relatively niche, so I will not comment here.
  6. Summary
    No development language is perfect, and neither is golang. But it’s efficient and easy to use, and if you’re wondering what you can do with Golang, you should look at what others are doing (like the well-known Go project on GitHub).
  7. Off topic
    Because of Golang’s simple design, developers are prone to writing weird code, at least in my observations.
    It may also be because of this that they prefer languages with higher syntactic sugar or more integrated libraries.

Do you know K8s is developed with Go?
I think that Go is very suitable for the Backend develop especially in Microservice architecture, only one compiled executive file with docker are very easy to do CICD deloy and autoscaling, etc.

For RESTful APIs, I haven’t found another language/ecosystem I prefer over Go yet. It’s almost purpose-built for building RESTful APIs (as evidenced by the stdlib being very capable in this regard without any external dependencies). Concurrency is easy and makes sense. It’s opinionated. Cross-compiling to different targets is easier than any other tool I’ve used. The ecosystem and tooling is excellent.

On cross-compiling, check this out:

https://www.reddit.com/r/golang/comments/13bfvqd/comment/jjb6xx7/?utm_source=share&utm_medium=web2x&context=3

And listen to the linked talk by Rob Pike. Here’s some other discussion on that point:

https://www.reddit.com/r/golang/comments/1dqf2ng/whats_the_secret_of_the_go_compiler_and_why_dont/

In my real-world experience with deploying production apps, Go-based APIs just perform better and are easier to reason about than the ones I build in other languages. This matters in the cloud platforms I’m targeting (mostly Google Cloud, AWS, and Azure) where memory/CPU is still somewhat expensive and a small footprint is important. And I’m not alone:

Beyond being able to quickly move to a more reliable platform, we’ve also managed to cut our infrastructure costs in half during this time period.

Other than that, I have used it to automate repetitive tasks because I’m faster writing Go usually than bash scripts. Plus, some of the developers on my team don’t use Linux and bash scripts aren’t cross-platform.

Another thing: of all the Excel libraries I’ve used, excelize is the best. So any project where I’m going to have to generate reports in Excel, I use Go if I have my druthers.

3 Likes

What framework(s) would you recommend for making a RESTful API on top of a database? I think Go is just about the best language out there for server code, except I haven’t yet found any Go framework that quite compares to FastAPI in Python. Maybe that’s not a fair comparison.

You can actually build entire REST API with standard library: json, net/http, sql/db etc. Give it a try. After that, go check ‘Gin framework’.

1 Like

You might appreciate the opinion of these seasoned PHP developers talking about the (mostly) pros and (some) cons of Migrating from PHP to Go.

I am really productive right now using mostly stdlib. Most of my new projects are using Postgres for DB and I use jackc/pgx which adds to database/sql things like bulk import, scan to slice/struct/slice of structs. etc. It also adds Postgres-only features.

I am unfamiliar with FastAPI but what are the features about it that you are missing? I checked out their example:

from typing import Union

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
    return {"item_id": item_id, "q": q}

… which doesn’t really look ALL that different from Go to me:

package main

import (
	"fmt"
	"log"
	"net/http"
)

func root(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, `{"Hello": "World"}`)
}

func readItem(w http.ResponseWriter, r *http.Request) {
	itemID := r.PathValue("item_id")
	q := r.URL.Query().Get("q")
	fmt.Fprintf(w, `{"item_id": %v, "q": "%v"}`, itemID, q)
}

func main() {
	http.HandleFunc("GET /", root)
	http.HandleFunc("GET /items/{item_id}", readItem)
	log.Fatal(http.ListenAndServe(":8089", nil))
}

Note that in the real world you would want to do some sanitization / checking here. But both of these examples are extremely contrived. :slight_smile:

With FastAPI, you get automatic data validation and a powerful dependency system. I did find some Go packages that are trying to implement a similar thing in Go (like GitHub - sashabaranov/go-fastapi: Create an API and get Swagger definition for free) so maybe I’ll have to check into those for future projects.