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.
What opens 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.
Windows
- VS Code
- GoLand
- any text editor
macOS
- VS Code
- GoLand
- any text editor
Linux
- VS Code
- vim
- any text editor
Open a .go file step by step
- Confirm the file really is a .go. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
- On Windows, open it with VS Code or GoLand.
- On Mac, use VS Code or GoLand.
- On Linux, try VS Code or vim.
- Still stuck? Convert the .go to exe (via go build), which opens more widely.
Why can't I open my .go file?
Almost always because no installed app understands Go. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.
The other possibility is that the file is not really a .go at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.
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 has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.
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. How sources are ranked and what is deliberately left out is set out in the methodology.