# How to Write Go Code

## Metadata
- Author: [[go.dev]]
- Full Title: How to Write Go Code
- Category: #articles
- Summary: This document provides a guide on how to write Go code. It covers topics such as code organization, creating a module, compiling and running a program, importing packages from the module, importing packages from remote modules, testing, and additional resources for learning Go. The document explains the concepts and provides examples to help beginners get started with writing Go code.
- URL: https://go.dev/doc/code
## Highlights
- Go programs are organized into packages. A package is a collection of source files in the same directory that are compiled together. Functions, types, variables, and constants defined in one source file are visible to all other source files within the same package. ([View Highlight](https://read.readwise.io/read/01jvt8dpy6tfx0cr2d1r013bbe))
- A module is a collection of related Go packages that are released together. A Go repository typically contains only one module, located at the root of the repository. ([View Highlight](https://read.readwise.io/read/01jvt8e6ewrdv10xft2xs2f12b))
- A file named `go.mod` there declares the module path: the import path prefix for all packages within the module. ([View Highlight](https://read.readwise.io/read/01jvt92fv12wndcwcrz57bh135))