BurntSushi / toml

TOML parser for Golang with reflection.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Skipped members generate invalid type error

davidnewhall opened this issue · comments

Hello! I'm curious if this code is expected to work. It's the smallest example I could come up with that reproduces my error. Some of my struct members are functions, and they have the - tag as shown here. I get an error trying to encode these structs. Is this a bug, or expected? Thanks!

package main

import (
	"bytes"
	"github.com/BurntSushi/toml"
)

func main() {
	var buf bytes.Buffer

	test := &struct {
		Func func() `toml:"-"`
	}{
		Func: main,
	}

	err := toml.NewEncoder(&buf).Encode(test)
	if err != nil {
		println(err.Error())
	}
}
// Output:
// unsupported type: func

Is this a bug, or expected? Thanks!

Neither; I just don't think it ever came up before.

I can't think of any reason why it shouldn't ignore this off-hand.