Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@e7
Created January 4, 2018 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e7/cf3a9e73bccd1935abd598c8027fe726 to your computer and use it in GitHub Desktop.
Save e7/cf3a9e73bccd1935abd598c8027fe726 to your computer and use it in GitHub Desktop.
golang的orm示例(mysql)
applist := make([]appinfo, 0)
for rows.Next() {
elmts := reflect.ValueOf(&appinfo{}).Elem()
onerow := make([]interface{}, elmts.NumField())
for i := 0; i < elmts.NumField(); i++ {
onerow[i] = elmts.Field(i).Addr().Interface()
}
rows.Scan(onerow...)
applist = append(applist, elmts.Interface().(appinfo))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment