sort.go
func column(s string, n int) (int, string) {
	if n == 0 {
		return 0, s
	}
	currentColumn := 0
	wstart := -1
	for i, c := range s {
		sp := unicode.IsSpace(c)
		switch {
		case !sp && wstart < 0: // Start of word
			currentColumn++
			wstart = i
		case sp && wstart >= 0 && currentColumn == n: // End of nth col
			return 0, s[wstart:i]
		case sp && wstart >= 0: // End of another column
			wstart = -1
		}
	}
	if wstart >= 0 && currentColumn == n { // nth column ends string
		return 0, s[wstart:]
	}

	// col not found. Treat as a value smaller than all strings
	return -1, ""
}
func column(s string, n int) (int, string) {
	if n == 0 {
		return 0, s
	}
	currentColumn := 0
	wstart := -1
	for i, c := range s {
		sp := unicode.IsSpace(c)
		switch {
		case !sp && wstart < 0: // Start of word
			currentColumn++
			wstart = i
		case sp && wstart >= 0 && currentColumn == n: // End of nth col
			return 0, s[wstart:i]
		case sp && wstart >= 0: // End of another column
			wstart = -1
		}
	}
	if wstart >= 0 && currentColumn == n { // nth column ends string
		return 0, s[wstart:]
	}

	// col not found. Treat as a value smaller than all strings
	return -1, ""
}
func column ( s string , n int ) ( int , string ) { if n == 0 { return 0 , s } currentColumn := 0 wstart := - 1 for i , c := range s { sp := unicode . IsSpace ( c ) switch { case ! sp && wstart < 0 : // Start of word currentColumn ++ wstart = i case sp && wstart >= 0 && currentColumn == n : // End of nth col return 0 , s [ wstart : i ] case sp && wstart >= 0 : // End of another column wstart = - 1 } } if wstart >= 0 && currentColumn == n { // nth column ends string return 0 , s [ wstart : ] } // col not found. Treat as a value smaller than all strings return - 1 , " " }
// column(s, n) returns 0,x where x is the nth column (1-based) in s,
// or -1,"" if s does not have n columns.  A zero column number is
// treated specially: 0,s is returned.
column ( s n ) returns 0 x where x is the nth column ( 1 - based ) in s or - 1 if s does not have n columns . A zero column number is treated specially : 0 s is returned .