Skip to content

Instantly share code, notes, and snippets.

@Casxt
Created July 17, 2018 17:32
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 Casxt/5354436ce1690dbe62d97762fdd3d67e to your computer and use it in GitHub Desktop.
Save Casxt/5354436ce1690dbe62d97762fdd3d67e to your computer and use it in GitHub Desktop.
[Golang] Use pointer to deal sql null value | 使用指针处理SQL NULL 值
var (
nullInt *int
nullTime *time.Time
nullString string
)
row := course.QueryRow("SELECT NULL,NULL,NULL FROM Table", LineID)
DBErr = row.Scan(&nullInt, &nullTime, &nullString);
if DBErr != nil {
return
}
if nullInt == nil{
}
if nullTime == nil {
}
if nullString == nil {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment