如何在Go结构(golang)中存储unicode

I am reading in unicode names in golang. My struct item is of type string, but this not correct I believe.

Is there an example of how to properly store unicode strings in a golang struct?

When I read the CSV document using csv.NewReader and print it to screen it works fine, but once in the struct as a string, it no longer prints correctly. This seems like a simple byte / string issue but I am having a hard time resolving it.

I tried using []byte in the struct, but then how do I do comparisons of the strings laters and what is the way I would print that []byte to a file correctly? Since I am writing to file as RDF, I suspect I need to convert to UTF-8 or something?

Go expects string data to be encoded as UTF-8. If your input data uses a different encoding, you will need to convert it to UTF-8 before assigning it to a string.

You can do this manually, or use a third party library like go-charset

It depends on what you mean by "unicode". Everything in Go is expected to be UTF-8, including the string datatype, so there's probably nothing you need to do (as long as you're dealing with UTF-8).

[]byte is just a series of bytes. It opaque to the data that's in it. You don't need to do anything special to write it to a file.

The stdlib has the unicode, unicode/utf8, and unicode/utf16 packages. There's also a normalization package if you need it here: http://godoc.org/golang.org/x/text/unicode/norm

This blog post can explain it in more depth than we can answer here, and has some links to more resources: http://blog.golang.org/strings