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) stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| elems | []string | Strings to join. |
| sep | string | Separator 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"}, "-")))}