DEV Community

loading...

Discussion on: Daily Challenge #1 - String Peeler

Collapse
margo1993 profile image
margo1993

Yesterday I started to discover golang, so i try do make these daily challenges in go.

My simple go solution

func RemoveFirstAndLastCharacterInWord(word string) (string, error) {
    wordLen := len(word)
    if wordLen < 3 {
        return "", errors.New("String: word is too short")
    }
    return word[1 : wordLen-1], nil
}
Forem Open with the Forem app