作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
var value_variable
// Access data from within a read-only transactional block.
db.View(func(tx *bolt.Tx) error {
v := tx.Bucket([]byte("people")).Get([]byte("john"))
fmt.Printf("John's last name is %s.\n", v)
return nil
})
如何给 value_variable 赋值?
最佳答案
因为 Go 是 lexically scoped ,您可以在传递给 View
的函数中分配 value_variable
:
var value_variable []byte
// Access data from within a read-only transactional block.
db.View(func(tx *bolt.Tx) error {
v := tx.Bucket([]byte("people")).Get([]byte("john"))
value_variable = v // <----- ASSIGN IT HERE
fmt.Printf("John's last name is %s.\n", v)
return nil
})
关于Golang bolt 获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29105275/
我是一名优秀的程序员,十分优秀!