rwxrob-dot/scripts/gomethods
Rob Muhlestein 2ea0289e9f Rebase
2022-02-09 02:29:05 -05:00

20 lines
407 B
Bash
Executable File

#!/usr/bin/env bash
_trim() {
local it="${1#"${1%%[![:space:]]*}"}"
echo -e "${it%"${it##*[![:space:]]}"}"
}
receiver="$1"
while IFS= read -r name; do
name=$(_trim "$name")
[[ -z "$name" ]] && continue
printf "func (r *%s) %s() string {return r.%s}\n" \
"$receiver" "${name^}" "${name,}"
printf "func (r *%s) Set%s(v string) {r.%s = v}\n" \
"$receiver" "${name^}" "${name,}"
done