mirror of
https://github.com/rwxrob/dot
synced 2024-11-16 21:25:29 +00:00
20 lines
407 B
Plaintext
20 lines
407 B
Plaintext
|
#!/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
|
||
|
|
||
|
|