Hello World, Golang!

GoGoBeginner
Practice Now

This tutorial is from open-source community. Access the source code

Introduction

This Golang challenge aims to test your basic understanding of the language syntax and structure. You will be required to write a simple program that prints the classic "hello world" message.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL go(("`Go`")) -.-> go/DataTypesandStructuresGroup(["`Data Types and Structures`"]) go/DataTypesandStructuresGroup -.-> go/strings("`Strings`") subgraph Lab Skills go/strings -.-> lab-15400{{"`Hello World, Golang!`"}} end

Hello World

Write a program that prints the message "hello world" to the console.

Requirements

  • The program should use the fmt package to print the message.
  • The program should be written in Golang.

Example

## To run the program, put the code in `hello-world.go` and
## use `go run`.
$ go run hello-world.go
hello world

## Sometimes we'll want to build our programs into
## binaries. We can do this using `go build`.
$ go build hello-world.go
$ ls
hello-world hello-world.go

## We can then execute the built binary directly.
$ ./hello-world
hello world

## Now that we can run and build basic Go programs, let's
## learn more about the language.

Summary

In this challenge, you were required to write a simple Golang program that prints the message "hello world" to the console. This challenge tests your basic understanding of the Golang syntax and structure.

Other Go Tutorials you may like