Code With Go
  • Code With Go
  • 01. What, Who, Why and Where?
  • 02. Compiled vs Interpreted languages
  • 03. Types of Type!
  • 04. Stack and Heap Memory
  • 05. Garbage Collection
  • 06. About Go
  • 07. Go Playground
  • 08. Hello, World!
  • 09. Installing Go
  • 10. Variables
  • 11. Constants
  • 12. Integers
  • 12. Floats
  • 13. Boolean
  • 14. Strings
  • 15. Complex Numbers
  • 16. If Else
  • 17. Switch
  • 18. For
  • 19. User Defined Types
  • 20. Arrays
  • 21. Slices
  • 22. Structs
  • 23. Maps
  • 24. Functions
  • 25. Defer
  • 26. Pointers
  • 27. Methods
  • Resources
    • Resources - Paid
    • Resources - Free
Powered by GitBook
On this page

Was this helpful?

07. Go Playground

Run without installing!

Previous06. About GoNext08. Hello, World!

Last updated 5 years ago

Was this helpful?

The Go Playground is a web service that runs on 's servers.

We can use Go playground to edit and run simple Go programs. Head to playground at :

Delete existing code and type in below code manually. (Remember programming is all about muscle memory!)

hello.go
package main

import "fmt"

func main() {
	fmt.Println("Hello, Pune!")
}

Let's understand how this code works:

Every Go program starts execution from main()

func main(){}

Main is the signal to compiler to start execution of code from here. This is entry point of our application.

Every Go program should be part of a package

package main

This declares that our program is part of package "main". Packages are used to bundle similar code that can be reused easily.

Go program can use external packages using import

import "fmt"

We are importing fmt package using import statement. Compiler will find this package and import in our program before we can use it.

We are using Println method from fmt package to print output to console. How to print output to console is implemented by fmt package, we do not have to write (re-write!) code to do it!

golang.org
https://play.golang.org/