Home > Backend Development > Golang > What Standard Library Packages Can Be Imported in the Go Playground?

What Standard Library Packages Can Be Imported in the Go Playground?

Susan Sarandon
Release: 2024-11-28 03:38:18
Original
253 people have browsed it

What Standard Library Packages Can Be Imported in the Go Playground?

Packages Importable in the Go Playground

Q: What packages can be imported when using the Go playground (http://play.golang.org/)?

A: The Go playground allows imports from most packages within the standard library, as stated in the “About” button on the playground.

Exceptions to Importability

The standard library packages that cannot be imported in the playground are:

  • Packages not found in the "Packages" page under the "Standard library" section.
  • Runtime packages with missing Go type information (e.g., runtime/cgo).

Playground Implementation

For a detailed explanation of the playground implementation, refer to "Inside the Go Playground" published on the Go Blog.

Exhaustive Playground Test

The following code demonstrates the importability of all standard library packages (excluding non-buildable packages):

package main

import (
    // ... imports for all standard library packages listed in the "Packages" page ...
)

func main() {
    println("ok")
}
Copy after login

This code imports all standard library packages except runtime/cgo, which gives a compilation error due to missing Go type information.

The above is the detailed content of What Standard Library Packages Can Be Imported in 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