How to concatenate strings in Go

2 Answers

0 votes
package main
  
import (
    "fmt"
)
  
func main() {
    const s1, s2, s3 = "abc", "xyz", "uvw"
  
    s := fmt.Sprintf("%s, %s, %s\n", s1, s2, s2) 

    fmt.Println(s)
}
  
  
  
  
/*
run:
  
abc, xyz, xyz
  
*/

 



answered May 27, 2020 by avibootz
0 votes
package main
  
import (
    "fmt"
)
  
func main() {
    const s1, s2, s3 = "abc", "xyz", "uvw"
  
    s := s1 + ", " + s2 + ", " + s3

    fmt.Println(s)
}
  
  
  
  
/*
run:
  
abc, xyz, xyz
  
*/

 



answered May 27, 2020 by avibootz
...