Home »
Golang »
Golang FAQ
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 »