You can split a string into two parts in Go by using the strings
package's Split
function. The Split
function takes three arguments: the string to split, the separator to use, and the maximum number of splits to perform. If you only want to split the string into two parts, you can pass in a 1
for the maximum number of splits to perform.
main.go386 chars22 lines
Output:
main.go49 chars3 lines
gistlibby LogSnag