游乐场可以导入哪些软件包? [英] Which packages may be imported in the go playground?

查看:146
本文介绍了游乐场可以导入哪些软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法找到可在 http://play.golang上的操场上导入哪些软件包的列表。组织/ 。我正在尝试使用(显然是实验性的)软件包来 ebnf 。然而,即使是一个简短的程序也不会从 golang.org (第4行的导入中断)导入:

  package main 

importfmt
importgolang.org/x/exp/ebnf

const g =`
Production = name=[Expression]。 。
Expression = Alternative {|替代}。
Alternative = Term {Term}。
Term = name |标记[...标记] | Group |选项|重复 。
Group =(Expression)。
Option =[Expression]。
Repetition ={Expression}.`

func main(){
fmt.Println(g)
}

是否在任何地方声明只有 golang.org/src/ 将导入(如果是这种情况)?



我真的很想玩这个实验包,甚至非实验补充库,如 currency

关于关于Playground的按钮给出了一些提示: / b>


操场可以使用大部分标准库,但有一些例外。


标准库标准库的包是指在
软件包 页面,un请访问 标准库 部分。在 其他 部分下列出的软件包不符合条件(这是您拥有的尝试 - 打包 golang.org/x/exp/ebnf 属于其他类别下列出的试用版和不赞成使用的软件包)。

必读链接if您想了解有关Playground实施的更多信息:



围棋博客:围棋围棋



这是一个详尽的操场测试,用于导入所有标准库程序包以显示它们可以导入,但这并不意味着所有的东西(甚至任何东西)都可以合理地从它们中使用。提供编译错误的标准库中的唯一包是 runtime / cgo ;没有可构建的Go源文件的包不包括在内,原因很明显(因为文件夹是不是包< a>如果它不包含至少一个可构建的Go源文件)。



这是

 包主

导入(
_archive / tar
_archive / zip

_bufio
_bytes

_compress / bzip2
_compress / flate
_compress / gzip
_compress / lzw
_compress / zlib

container / heap
_container / list
_container / ring

_crypto
_ crypto / aes
_crypto / cipher
_crypto / des
_crypto / dsa
_crypto / ecdsa
_ crypto / elliptic
_crypto / hmac
_crypto / md5
_crypto / rand
_crypto / rc4
_crypto / rsa
_crypto / sha1
_crypto / sha256
_crypto / sha512
_crypto / subtle
_crypto / tls
_crypto / x509
_crypto / x509 / pkix

_database / sql
_database / sql / driver

_debug / dwarf
_debug / elf
$debug / gosym
_debug / macho
_debug / pe
_debug / plan9obj

_encoding
_encoding / ascii85
_encoding / asn1
_encoding / base32
_encoding / base64
_encoding / binary
_encoding / csv
_encoding / gob
_encoding / hex
_encoding / json
_encoding / pem
_encoding / xml

_errors
_expvar
_flag
_fmt

_go / ast
_go / build
_go / constant
_go / doc
_go / format
_go / importer
_go / parser
_go / printer
_go / scanner
_go / token
_go / types

_hash
_hash / adler32
_hash / crc32
_hash / crc64
_hash / fnv

_html
_html / template

_image
_image / color
_image / color / palette
_image / draw
_image / gif
_image / jpeg
_ image / png

_index / suffixarray

_io
_io / ioutil

_ log
_log / syslog

_math
_math / big
_math / cmplx
_ math / rand

_mime
_mime / multipart
_mime / quotedprintable

_net
_net / http
_net / http / cgi
_net / http / cookiejar
_net / http / fcgi
_ net / http / httptest
_net / http / httputil
_net / http / pprof
_net / mail
_net / rpc
_net / rpc / jsonrpc
_net / smtp
_net / textproto
_net / url

_os
_os / exec
_os / signal
_os / user

_path
_path / filepath

_reflect
_regexp
_regexp / syntax

_runtime
// _runtime / cgo//错误:缺少Go类型信息
// for全局符号:.dynsym大小60
_runtime / debug
_runtime / pprof
_runtime / race
_runtime / trace

sort
_strconv
_strings
_sync
_sync / atomic
_系统调用

_测试
_测试/ iotest
_测试/快速

_text / scanner
_text / tabwriter
_text / template
_text / template / parse

_time
_unicode
_unicode / utf16
_unicode / utf8
_unsafe


func main(){
println(ok)
}


I had trouble finding a list of what packages may be imported in the go playground at http://play.golang.org/. I was trying to use the (apparently experimental) package for ebnf. However even a short program won't import from golang.org (breaks on the import on line 4):

package main

import "fmt"
import "golang.org/x/exp/ebnf"

const g = `
Production  = name "=" [ Expression ] "." .
Expression  = Alternative { "|" Alternative } .
Alternative = Term { Term } .
Term        = name | token [ "…" token ] | Group | Option | Repetition .
Group       = "(" Expression ")" .
Option      = "[" Expression "]" .
Repetition  = "{" Expression "}" .`

func main() {
    fmt.Println(g)
}

Is it stated anywhere that only base packages in golang.org/src/ would import (if that's the case)?

I'd really like to play with this experimental package and even non-experimental supplemental libraries like currency in the playground.

解决方案

The About button on the Playground gives some hint:

The playground can use most of the standard library, with some exceptions.

By the standard library the packages of the standard library are meant, which are listed on the Packages page, under the Standard library section. Packages listed under the Other section do not qualify (which is what you have tried - package golang.org/x/exp/ebnf falls under the experimental and deprecated packages listed under the Other category).

A must-read link if you want to know more about the Playground implementation:

The Go Blog: Inside the Go Playground

Here is an exhaustive playground test to import all the standard library packages to show they at least can be imported, but that doesn't mean everything (or even anything) can be reasonably used from them. The only package from the standard library that gives a compile error is runtime/cgo; "packages" without a buildable Go source file are not included for obvious reasons (because a folder is not a package if it does not contain at least one buildable Go source file).

Here's the Playground Link to try it yourself.

package main

import (
    _ "archive/tar"
    _ "archive/zip"

    _ "bufio"
    _ "bytes"

    _ "compress/bzip2"
    _ "compress/flate"
    _ "compress/gzip"
    _ "compress/lzw"
    _ "compress/zlib"

    _ "container/heap"
    _ "container/list"
    _ "container/ring"

    _ "crypto"
    _ "crypto/aes"
    _ "crypto/cipher"
    _ "crypto/des"
    _ "crypto/dsa"
    _ "crypto/ecdsa"
    _ "crypto/elliptic"
    _ "crypto/hmac"
    _ "crypto/md5"
    _ "crypto/rand"
    _ "crypto/rc4"
    _ "crypto/rsa"
    _ "crypto/sha1"
    _ "crypto/sha256"
    _ "crypto/sha512"
    _ "crypto/subtle"
    _ "crypto/tls"
    _ "crypto/x509"
    _ "crypto/x509/pkix"

    _ "database/sql"
    _ "database/sql/driver"

    _ "debug/dwarf"
    _ "debug/elf"
    _ "debug/gosym"
    _ "debug/macho"
    _ "debug/pe"
    _ "debug/plan9obj"

    _ "encoding"
    _ "encoding/ascii85"
    _ "encoding/asn1"
    _ "encoding/base32"
    _ "encoding/base64"
    _ "encoding/binary"
    _ "encoding/csv"
    _ "encoding/gob"
    _ "encoding/hex"
    _ "encoding/json"
    _ "encoding/pem"
    _ "encoding/xml"

    _ "errors"
    _ "expvar"
    _ "flag"
    _ "fmt"

    _ "go/ast"
    _ "go/build"
    _ "go/constant"
    _ "go/doc"
    _ "go/format"
    _ "go/importer"
    _ "go/parser"
    _ "go/printer"
    _ "go/scanner"
    _ "go/token"
    _ "go/types"

    _ "hash"
    _ "hash/adler32"
    _ "hash/crc32"
    _ "hash/crc64"
    _ "hash/fnv"

    _ "html"
    _ "html/template"

    _ "image"
    _ "image/color"
    _ "image/color/palette"
    _ "image/draw"
    _ "image/gif"
    _ "image/jpeg"
    _ "image/png"

    _ "index/suffixarray"

    _ "io"
    _ "io/ioutil"

    _ "log"
    _ "log/syslog"

    _ "math"
    _ "math/big"
    _ "math/cmplx"
    _ "math/rand"

    _ "mime"
    _ "mime/multipart"
    _ "mime/quotedprintable"

    _ "net"
    _ "net/http"
    _ "net/http/cgi"
    _ "net/http/cookiejar"
    _ "net/http/fcgi"
    _ "net/http/httptest"
    _ "net/http/httputil"
    _ "net/http/pprof"
    _ "net/mail"
    _ "net/rpc"
    _ "net/rpc/jsonrpc"
    _ "net/smtp"
    _ "net/textproto"
    _ "net/url"

    _ "os"
    _ "os/exec"
    _ "os/signal"
    _ "os/user"

    _ "path"
    _ "path/filepath"

    _ "reflect"
    _ "regexp"
    _ "regexp/syntax"

    _ "runtime"
    // _ "runtime/cgo"  // ERROR: missing Go type information
                        // for global symbol: .dynsym size 60
    _ "runtime/debug"
    _ "runtime/pprof"
    _ "runtime/race"
    _ "runtime/trace"

    _ "sort"
    _ "strconv"
    _ "strings"
    _ "sync"
    _ "sync/atomic"
    _ "syscall"

    _ "testing"
    _ "testing/iotest"
    _ "testing/quick"

    _ "text/scanner"
    _ "text/tabwriter"
    _ "text/template"
    _ "text/template/parse"

    _ "time"
    _ "unicode"
    _ "unicode/utf16"
    _ "unicode/utf8"
    _ "unsafe"
)

func main() {
    println("ok")
}

这篇关于游乐场可以导入哪些软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆