Get reputation Badge from given score I have written code that gets the reputation badge from given score like this:

I use an if-else statement here:

func GetReputationBadge2(score int) string {

    badge := "badges-off.jpg"
    if score &gt;= 50001 { // Diamond
        badge = "diamond-1.gif"
        if score &gt;= 500001 {
            badge = "diamond-5.gif"
        } else if score &gt;= 200001 {
            badge = "diamond-4.gif"
        } else if score &gt;= 150001 {
            badge = "diamond-3.gif"
        } else if score &gt;= 100001 {
            badge = "diamond-2.gif"
        }
    } else if score &gt;= 4501 { // Gold
        badge = "gold-1.gif"
        if score &gt;= 45001 {
            badge = "gold-5.gif"
        } else if score &gt;= 30001 {
            badge = "gold-4.gif"
        } else if score &gt;= 15001 {
            badge = "gold-3.gif"
        } else if score &gt;= 10001 {
            badge = "gold-4.gif"
        }
    }

    return badge
}


I was kinda thinking that I could make it better using a switch-case statement:

func GetReputationBadge(score int) string {

    badge := "badges-off.jpg"
    caseSwitch := true
    switch caseSwitch {
    case score &gt;= 50001:
        badge = "diamond-1.gif"

        switch caseSwitch {
        case score &gt;= 500001:
            badge = "diamond-5.gif"
        case score &gt;= 200001:
            badge = "diamond-4.gif"
        case score &gt;= 150001:
            badge = "diamond-3.gif"
        case score &gt;= 100001:
            badge = "diamond-2.gif"

        }

    case score &gt;= 4501:
        badge = "gold-1.gif"

        switch caseSwitch {
        case score &gt;= 45001:
            badge = "gold-5.gif"
        case score &gt;= 30001:
            badge = "gold-4.gif"
        case score &gt;= 15001:
            badge = "gold-3.gif"
        case score &gt;= 10001:
            badge = "gold-2.gif"

        }

    default:
        return badge
    }

    return badge
}


Notice that I'm comparing boolean in the switch-case statement. Which are better for performance: using if-else or switch-case statement in this case?
For just a few items, the difference is small. If you have many items you should definitely use a switch.

This question might help: https://stackoverflow.com/questions/29566229/go-switch-string-efficiency