golang -- ToString

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

String concatenation

package str

import (
    "strconv"
)

func ToString(args ...interface{}) string {
    result := ""
    for _, arg := range args {
        switch val := arg.(type) {
            case int:
                result += strconv.Itoa(val)
            case string:
                result += val
        }
    }
    return result
}



The use of ToString("abcd", 12, 45)
=> abcd1245

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Tessa at January 16, 2014 - 7:23 PM