Standard library / strings

strings.Join()

Concatenates elements with the separator inserted between adjacent elements, never after the last. Expected stdout: 'a-b\n'.

Formal Syntax & Structure

go syntaxgo
func Join(elems []string, sep string) string

Parameters & Attributes

NameTypeDescription
elems[]stringStrings to join.
sepstringSeparator or search sequence.

Return Value

string

Concatenates elements with the separator inserted between adjacent elements, never after the last.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings")
func main() {  fmt.Println(string(strings.Join([]string{"a", "b"}, "-")))}
Go Reference