0 votes
in GoLang by
Format a string without printing it

1 Answer

0 votes
by

Find the easiest way to format a string with variables without printing the value.

Solution

The easiest way to format without printing is to use the fmt.Sprintf(), which returns a string without printing it.

For example:

package main

import "fmt"

func main() {

  s := fmt.Sprintf("Size: %d MB.", 85)

  fmt.Println(s)

}

Related questions

0 votes
asked Aug 11, 2022 in GoLang by SakshiSharma
0 votes
asked Aug 19, 2022 in GoLang by john ganales
...