Home > Article > Backend Development > Can You Import Third-Party Packages into the Go Playground?
Question:
Can users import third-party packages into the Go Playground? If so, how?
Answer:
Yes, it is now possible to import third-party packages into the Go Playground. This feature was added on May 14th, 2019.
How to Import Third-Party Packages:
To import a third-party package into the Go Playground, use the import statement as you would normally do in a Go program. The only difference is that you need to use the special URL https://proxy.golang.org/ as the package path:
import ( "fmt" "github.com/gonum/gonum/mat" ) func main() { v1 := mat.NewVecDense(4, []float64{1, 2, 3, 4}) fmt.Println(mat.Dot(v1, v1)) }
This will import the gonum/mat package, even though it is not part of the Go Standard Library.
Limitations:
Although importing third-party packages is now possible, there are some limitations. For example, network access is restricted in the Go Playground, so any packages that require network connectivity may not work as expected.
The above is the detailed content of Can You Import Third-Party Packages into the Go Playground?. For more information, please follow other related articles on the PHP Chinese website!