Syntax

Go Package and Main Syntax

In Go, package and main: the entry point of a Go program — package main func main() { }

Quick Answer

Syntax
package main func main() { }
GoSyntax

Package and Main

Code example
package main func main() { }

The entry point of a Go program.

Learn More

How to package and main in Go

  1. Open your Go file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Go Package and Main Syntax

Use package main func main() { }.

Related Syntax References

Frequently asked questions

What is the Go syntax for package and main?

Use this pattern: package main func main() { }

Can I copy this Go code example?

Yes. Use Copy code and adapt the example to your program.

Is this Go syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify