diff options
author | V3n3RiX <venerix@koprulu.sector> | 2023-06-14 15:21:15 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2023-06-14 15:21:15 +0100 |
commit | 1c382dc5dbc52576ac2300fee0498af8af44e7b4 (patch) | |
tree | 45d2492f5c659cbb01120d4192c9be34841362bd /eclass/go-module.eclass | |
parent | b9e8f3cc44aed3b6da71c7510c6287bf7bbbc66b (diff) |
Revert "gentoo auto-resync : 14:06:2023 - 15:13:45"
This reverts commit b9e8f3cc44aed3b6da71c7510c6287bf7bbbc66b.
Diffstat (limited to 'eclass/go-module.eclass')
-rw-r--r-- | eclass/go-module.eclass | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass index 6c58d7f26f07..f97b69f591c8 100644 --- a/eclass/go-module.eclass +++ b/eclass/go-module.eclass @@ -262,22 +262,7 @@ go-module_set_globals() { continue fi - # Encode the name(path) of a Golang module in the format expected by Goproxy. - # Upper letters are replaced by their lowercase version with a '!' prefix. - # The transformed result of 'module' is stored in the '_dir' variable. - # - ## Python: - # return re.sub('([A-Z]{1})', r'!\1', s).lower() - ## Sed: - ## This uses GNU Sed extension \l to downcase the match - # echo "${module}" |sed 's,[A-Z],!\l&,g' - local re _dir lower - _dir="${module}" - re='(.*)([A-Z])(.*)' - while [[ ${_dir} =~ ${re} ]]; do - lower='!'"${BASH_REMATCH[2],}" - _dir="${BASH_REMATCH[1]}${lower}${BASH_REMATCH[3]}" - done + _dir=$(_go-module_gomod_encode "${module}") for _ext in "${exts[@]}" ; do # Relative URI within a GOPROXY for a file @@ -511,6 +496,33 @@ go-module_live_vendor() { popd >& /dev/null || die } +# @FUNCTION: _go-module_gomod_encode +# @DEPRECATED: none +# @DESCRIPTION: +# Encode the name(path) of a Golang module in the format expected by Goproxy. +# +# Upper letters are replaced by their lowercase version with a '!' prefix. +# +_go-module_gomod_encode() { + ## Python: + # return re.sub('([A-Z]{1})', r'!\1', s).lower() + + ## Sed: + ## This uses GNU Sed extension \l to downcase the match + #echo "${module}" |sed 's,[A-Z],!\l&,g' + # + # Bash variant: + debug-print-function "${FUNCNAME}" "$@" + #local re input lower + re='(.*)([A-Z])(.*)' + input="${1}" + while [[ ${input} =~ ${re} ]]; do + lower='!'"${BASH_REMATCH[2],}" + input="${BASH_REMATCH[1]}${lower}${BASH_REMATCH[3]}" + done + echo "${input}" +} + fi if [[ ! ${GO_OPTIONAL} ]]; then |