1 Star 1 Fork 0

bigbase / pg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
hstore_parser.go 723 Bytes
一键复制 编辑 原始数据 按行查看 历史
package parser
import "fmt"
type HstoreParser struct {
*Parser
}
func NewHstoreParser(b []byte) *HstoreParser {
return &HstoreParser{
Parser: New(b),
}
}
func (p *HstoreParser) NextKey() ([]byte, error) {
if p.Skip(',') {
p.Skip(' ')
}
if !p.Skip('"') {
return nil, fmt.Errorf("pg: can't parse hstore key: %q", p.Bytes())
}
key := p.readSubstring()
if !(p.Skip('=') && p.Skip('>')) {
return nil, fmt.Errorf("pg: can't parse hstore key: %q", p.Bytes())
}
return key, nil
}
func (p *HstoreParser) NextValue() ([]byte, error) {
if !p.Skip('"') {
return nil, fmt.Errorf("pg: can't parse hstore value: %q", p.Bytes())
}
value := p.readSubstring()
p.SkipBytes([]byte(", "))
return value, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/bigbase/pg.git
git@gitee.com:bigbase/pg.git
bigbase
pg
pg
v6.4.24

搜索帮助

344bd9b3 5694891 D2dac590 5694891