reflect: print struct tags in Type.String() (with a caveat)
Этот коммит содержится в:
родитель
1a60a1f526
коммит
e7bd22edf2
1 изменённых файлов: 7 добавлений и 0 удалений
|
@ -551,6 +551,13 @@ func (t *rawType) String() string {
|
|||
for i := 0; i < numField; i++ {
|
||||
f := t.rawField(i)
|
||||
s += " " + f.Name + " " + f.Type.String()
|
||||
if f.Tag != "" {
|
||||
// TODO(dgryski): The tag should be
|
||||
// double-quoted and escaped; that requires
|
||||
// strconv and reflectlite or our own Quote()
|
||||
// implementation
|
||||
s += " " + string(f.Tag)
|
||||
}
|
||||
// every field except the last needs a semicolon
|
||||
if i < numField-1 {
|
||||
s += ";"
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче