0% found this document useful (0 votes)
8 views1 page

Go (Golang) Advanced Lab

The document is a lab manual for advanced programming in Go (Golang), featuring an example of using goroutines. It includes a code snippet that demonstrates how to print numbers concurrently while the main function continues to execute. The output shows the numbers printed followed by a message indicating the main function has finished.

Uploaded by

hitsaiml2c
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Go (Golang) Advanced Lab

The document is a lab manual for advanced programming in Go (Golang), featuring an example of using goroutines. It includes a code snippet that demonstrates how to print numbers concurrently while the main function continues to execute. The output shows the numbers printed followed by a message indicating the main function has finished.

Uploaded by

hitsaiml2c
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Go (Golang) Advanced Programming

Lab
Lab Manual: Advanced Level Programs

Contents:

1. 1. Goroutines Example

1. Goroutines Example
Code:

package main
import (
"fmt"
"time"
)
func printNumbers() {
for i := 1; i <= 5; i++ {
fmt.Println(i)
time.Sleep(500 * time.Millisecond)
}
}
func main() {
go printNumbers()
time.Sleep(3 * time.Second)
fmt.Println("Main function finished")
}

Output:

1
2
3
4
5
Main function finished

You might also like