Can You Import Third-Party Packages into the Go Playground?

Patricia Arquette
Release: 2024-11-20 03:38:02
Original
531 people have browsed it

Can You Import Third-Party Packages into the Go Playground?

Importing Third-Party Packages in 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))
}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template