将nil附加到slice会得到0值

Appending a nil value to a slice of interfaces results in a slice holding a 0 value. [0]

var values []interface{}

values = append(values, nil)

However doing this,

values[0] = nil

does what I expected. It results in a slice holding a nil value

[<nil>]

I need the nil value to pass to my db driver. What is going on here?

I cannot reproduce your issue: append(values, nil) properly appends a nil wrapped as an interface:

package main
import "fmt"
func main() {
     var values []interface{}
     values = append(values, nil)
     fmt.Printf("%#v", values) // == []interface {}{interface {}(nil)}
}

See http://play.golang.org/p/-unk6Hdt