LoginSignup
31
25

More than 5 years have passed since last update.

stringからio.Readerへの変換したい

Posted at

testとかで使いたいと思ったタイミングがありました。

main.go
package main

import (
    "fmt"
    "strings"
)

func main() {

    r:=strings.NewReader("(1,2,34,55,666)")
    var d [5]int
    fmt.Fscanf(r,"(%d,%d,%d,%d,%d)",&d[0],&d[1],&d[2],&d[3],&d[4])
    fmt.Println(d)
}

31
25
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
25