Answers for "decorator in golang"

Go
0

golang decorator

// this is the type of functions you want to decorate
type StringManipulator func(string) string

// this is your decorator.
func ToLower(m StringManipulator) StringManipulator {
    return func(s string) string {
        lower := strings.ToLower(s)
        return m(lower)
    }
}
Posted by: Guest on June-02-2021

Browse Popular Code Answers by Language