本文整理汇总了Golang中fmt.Sscanln函数的典型用法代码示例。如果您正苦于以下问题:Golang Sscanln函数的具体用法?Golang Sscanln怎么用?Golang Sscanln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sscanln函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: parseLine
// Parse an individual line from Linux's /proc/net/dev.
func (nic *NICSampler) parseLine(line string) (err error) {
var dev string
var rx_byte, rx_pkt, rx_err, rx_drop uint64
var rx_fifo, rx_frame, rx_comp, rx_mcast uint64
var tx_byte, tx_pkt, tx_err, tx_drop uint64
var tx_fifo, tx_coll, tx_carr, tx_comp uint64
if strings.Contains(line, "|") {
return
}
_, err = fmt.Sscanln(line,
&dev,
&rx_byte, &rx_pkt, &rx_err, &rx_drop,
&rx_fifo, &rx_frame, &rx_comp, &rx_mcast,
&tx_byte, &tx_pkt, &tx_err, &tx_drop,
&tx_fifo, &tx_coll, &tx_carr, &tx_comp)
if err != nil {
return
}
dev = dev[0 : len(dev)-1]
if strings.HasPrefix(dev, "lo") {
return
}
nic.sink.Write("net",
dev,
rx_byte, rx_pkt, rx_err, rx_drop,
tx_byte, tx_pkt, tx_err, tx_drop)
return
}
开发者ID:codeslinger,项目名称:monitor,代码行数:30,代码来源:standard.go
示例2: Scanln
func (fakeUi *FakeUi) Scanln(args ...interface{}) (int, error) {
fakeUi.Args = args
fmt.Sscanln(fakeUi.UserInput, args[0])
return fakeUi.ScanlnRc, fakeUi.ScanlnErr
}
开发者ID:cloudfoundry-community,项目名称:bosh-softlayer-tools,代码行数:7,代码来源:fake_ui.go
示例3: GetOwner
// Who owns the lockfile?
func (l Lockfile) GetOwner() (*os.Process, error) {
name := string(l)
// Ok, see, if we have a stale lockfile here
content, err := ioutil.ReadFile(name)
if err != nil {
return nil, err
}
var pid int
_, err = fmt.Sscanln(string(content), &pid)
if err != nil {
return nil, ErrInvalidPid
}
// try hard for pids. If no pid, the lockfile is junk anyway and we delete it.
if pid > 0 {
p, err := os.FindProcess(pid)
if err != nil {
return nil, err
}
return p, isProcessAlive(p)
} else {
return nil, ErrInvalidPid
}
panic("Not reached")
}
开发者ID:kovetskiy,项目名称:lockfile,代码行数:28,代码来源:lockfile.go
示例4: boxFromString
// boxFromString returns the box defined by a string of the form "x y w h id".
func boxFromString(in string) (b box, err error) {
_, err = fmt.Sscanln(in, &b.x, &b.y, &b.w, &b.l, &b.id)
if b == emptybox {
return b, errEmpty
}
if b.w == 0 && b.l == 0 {
return b, errZeroBox
}
return
}
开发者ID:billyboar,项目名称:GCSolutions,代码行数:11,代码来源:pallet.go
示例5: main
func main() {
str := "34 343 245"
var a, b, c int
fmt.Sscan(str, &a, &b, &c)
fmt.Println(a, b, c)
fmt.Sscanf(str, "%d %d %d", &a, &b, &c)
fmt.Println(a, b, c)
fmt.Sscanln(str, &a, &b, &c)
fmt.Println(a, b, c)
}
开发者ID:cwen-coder,项目名称:study-gopkg,代码行数:10,代码来源:Sscan.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng