Skip to content
This repository was archived by the owner on May 24, 2023. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: VividCortex/go-database-sql-tutorial
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: gh-pages
Choose a base ref
...
head repository: liyuankui/go-database-sql-tutorial
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: patch-1
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jun 5, 2018

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    706f4ce View commit details
Showing with 16 additions and 0 deletions.
  1. +16 −0 nulls.md
16 changes: 16 additions & 0 deletions nulls.md
Original file line number Diff line number Diff line change
@@ -53,6 +53,22 @@ for rows.Next() {
}
</pre>

Another trick to handle NULLs without using nullable types.

Use pointers.

<pre class="prettyprint lang-go">
for rows.Next() {
var s *string
err := rows.Scan(&amp;s)
// check err
if s != nil {
// use s.String
} else {
// NULL value
}
}
</pre>

**Previous: [Handling Errors](errors.html)**
**Next: [Working with Unknown Columns](varcols.html)**