LoginSignup
13
9

More than 5 years have passed since last update.

golangでchomp

Posted at
package main

import (
    "fmt"
    "strings"
)

func main() {
    foo := "hooo\n"
    bar := "bar\n"

    fmt.Printf("foo is %s bar is %s", foo, bar)
    // foo is hooo
    // bar is bar
    foo = strings.TrimRight(foo, "\n")
    bar = strings.TrimRight(bar, "\n")

    fmt.Printf("foo is %s bar is %s", foo, bar)
    // foo is hooo bar is bar
}
13
9
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
13
9