×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

What is factored import statement in Go language?

What is factored important statement, how to use factored important statement in Golang?
Submitted by IncludeHelp, on October 01, 2021

The "factored" import statement groups the imports into a parenthesized.

Syntax:

import (
	package_1
	package_2
	...
)

Example:

import (
	"fmt"
	"time"
)

In the below program, we are using two packages fmt and strings and these packages are importing through the factored import statement. The fmt package is using for the Println() and the strings package is using for ToUpper().

// Golang program to demonstrate the
// example of strings.ToUpper() Function

package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.ToUpper("hello, world!"))
	fmt.Println(strings.ToUpper("Hello, World!"))
}

Output:

HELLO, WORLD!
HELLO, WORLD!

Golang FAQ »



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.