What is a .go file?
Go Source File · Code and data · Google · 2009
A .go file is source code for the Go programming language, a fast, compiled language from Google built for servers, networking and command-line tools. It is plain text compiled into a single standalone binary.
What is a .go file used for?
Go source is famously simple and consistent, with a built-in formatter (gofmt) that gives every file the same style. A program is built with go build, producing one self-contained executable with no external runtime.
Go powers a lot of cloud infrastructure, including Docker and Kubernetes. The files are plain text and open in any editor; VS Code with the Go extension adds tooling.
How to open a .go file
The .go format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .go file.
Windows
- VS Code
- GoLand
- any text editor
macOS
- VS Code
- GoLand
- any text editor
Linux
- VS Code
- vim
- any text editor
How to convert a .go file
You can convert a .go file to exe (via go build) using a conversion tool or the export menu of an app that opens it.
.go file signature (magic bytes)
Programs recognise a .go file by the bytes at the start of the file, not by its name. These are the signatures for Go.
| Hex signature | Offset | Note |
|---|---|---|
| (no fixed signature) | 0 | plain text; no fixed magic bytes |
See the full magic-numbers reference for every format.
Frequently asked questions
What is a .go file?
A .go file is source code for the Go programming language, a fast, compiled language from Google built for servers, networking and command-line tools. It is plain text compiled into a single standalone binary.
How do I run a .go file?
With Go installed, run go run file.go to execute it, or go build to compile a standalone binary.
How do I open a .go file?
Any text editor shows the source. VS Code with the Go extension adds formatting, hints and debugging.
Do I need a runtime to run a Go program?
No. Go compiles to a single native binary that includes everything it needs, which is one reason it is popular for servers.
Related formats
Sources
Details on this page were checked against authoritative references: