package jenimport ()// Dict renders as key/value pairs. Use with Values for map or composite// literals.typeDictmap[Code]Code// DictFunc executes a func(Dict) to generate the value. Use with Values for// map or composite literals.func ( func(Dict)) Dict { := Dict{} ()return}func ( Dict) ( *File, io.Writer, *Statement) error { := true// must order keys to ensure repeatable sourcetypestruct {CodeCode } := map[string]{} := []string{}for , := range {if .isNull() || .isNull() {continue } := &bytes.Buffer{}if := .render(, , nil); != nil {return } = append(, .String()) [.String()] = {: , : } }sort.Strings()for , := range { := []. := [].if && len() > 1 {if , := .Write([]byte("\n")); != nil {return } = false }if := .render(, , nil); != nil {return }if , := .Write([]byte(":")); != nil {return }if := .render(, , nil); != nil {return }iflen() > 1 {if , := .Write([]byte(",\n")); != nil {return } } }returnnil}func ( Dict) ( *File) bool {if == nil || len() == 0 {returntrue }for , := range {if !.isNull() && !.isNull() {// if any of the key/value pairs are both not null, the Dict is not // nullreturnfalse } }returntrue}
The pages are generated with Goldsv0.8.4. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.