# Using Go workspaces in Kubernetes

DevFeed: [Using Go workspaces in Kubernetes](<https://devfeed.tech/articles/using-go-workspaces-in-kubernetes-17576.md>)

Original publisher: [Read original article](<https://www.kubernetes.dev/blog/2024/03/19/go-workspaces-in-kubernetes/>)

Author: The Kubernetes Authors

Published: 2024-03-19T16:30:00Z

Content type: tutorial

Language: en

Sources: [Kubernetes Contributors Blog](<https://devfeed.tech/sources/kubernetes-contributors-blog.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Kubernetes](<https://devfeed.tech/topics/kubernetes.md>), [Programming language](<https://devfeed.tech/topics/programming-language.md>), [Development](<https://devfeed.tech/topics/development.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Code generation](<https://devfeed.tech/topics/code-generation.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [development](<https://devfeed.tech/tags/development.md>), [go](<https://devfeed.tech/tags/go.md>), [go-development](<https://devfeed.tech/tags/go-development.md>), [go-programming](<https://devfeed.tech/tags/go-programming.md>), [kubernetes](<https://devfeed.tech/tags/kubernetes.md>), [open](<https://devfeed.tech/tags/open.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [programming](<https://devfeed.tech/tags/programming.md>)

## AI overview

This article explains Kubernetes's adoption of Go workspaces to simplify management of its multi-module codebase. It describes the historical use of GOPATH, staging, and Go modules, and reports that workspaces made the codebase simpler and less error-prone while reducing reliance on custom tooling and scripts.

## Source excerpt

The Go programming language has played a huge role in the success of Kubernetes. As Kubernetes has grown, matured, and pushed the bounds of what "regular" projects do, the Go project team has also grown and evolved the language and tools. In recent releases, Go introduced a feature called "workspaces" which was aimed at making projects like Kubernetes easier to manage. We've just completed a major effort to adopt workspaces in Kubernetes, and the results are great. Our codebase is simpler and less error-prone, and we're no longer off on our own technology island. GOPATH and Go modules Kubernetes is one of the most visible open source projects written in Go. The earliest versions of Kubernetes, dating back to 2014, were built with Go 1.3. Today, 10 years later, Go is up to version 1.22 -- and let's just say that a whole lot has changed. In 2014, Go development was entirely based on GOPATH . As a Go project, Kubernetes lived by the rules of GOPATH. In the buildup to Kubernetes 1.4 (mid 2016), we introduced a directory tree called staging. This allowed us to pretend to be multiple projects, but still exist within one git repository (which had advantages for development velocity). The magic of GOPATH allowed this to work. Kubernetes depends on several code-generation tools which have to find, read, and write Go code packages. Unsurprisingly, those tools grew to rely on GOPATH. This all worked pretty well until Go introduced modules in Go 1.11 (mid 2018). Modules were an answer to many issues around GOPATH. They gave more control to projects on how to track and manage dependencies, and were overall a great step forward. Kubernetes adopted them. However, modules had one major drawback -- most Go tools could not work on multiple modules at once. This was a problem for our code-generation tools and scripts. Thankfully, Go offered a way to temporarily disable modules (GO111MODULE to the rescue). We could get the dependency tracking benefits of modules, but the flexibility of G