Introduction
Importing packages lets you use code others wrote so you don't have to start from scratch.
import "package_name" // or to import multiple packages import ( "package_one" "package_two" )
import "fmt"
import ( "fmt" "math" )
import alias "fmt"
package main import "fmt" func main() { fmt.Println("Hello, importing packages!") }
fmt in Go?import followed by the package name in double quotes.import "fmt". Other options use incorrect keywords or missing quotes.fmt and math in Go?package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(math.Sqrt(16))
}fmt and math packages. It calls math.Sqrt(16) which returns the square root of 16 as a float64.math.Sqrt(16) returns 4.0 (float64). fmt.Println prints it as 4.0 including the decimal point because it is a float64 value.package main
import "fmt"
import "math"
func main() {
fmt.Println(math.Pow(2, 3))
}math.Pow(2, 3) is a valid function call to calculate 2 to the power 3.strings package but use it with the name str in your code. Which import statement is correct?import str "strings". Other options use invalid syntax not supported in Go.Pass the test and this pattern moves unknown