Go strings Package Join()

Introduction

To take a list of strings and join them together in a single string separated by another string (e.g., a comma), use the Join function:

package main /* w  w  w  . ja v a2 s  .  com*/

import ( 
    "fmt" 
    "strings" 
) 

func main() { 
    // func Join(a []string, sep string) string 
    fmt.Println(strings.Join([]string{"a","b"}, "-")) 
    // => "a-b" 
} 



PreviousNext

Related