From 379c776942eee18388be671d7c5cd260826ad38e Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 18 Dec 2023 17:04:13 +0100 Subject: [PATCH] fix: backport comparable check to <1.20 Signed-off-by: Mark Sagi-Kazar --- .devenv/profile | 1 + .direnv/bin/nix-direnv-reload | 19 ++ .../027wnc7kfpdl7n7xr7pby8csjd31d8xw-source | 1 + .../2gkqfvzq2j0vbrlkx3y0k8qxyn4px989-source | 1 + .../4yg9rk38xim0166ynim8ndxvh6qi4pcc-source | 1 + .../88fpp9lrbs0vk8yf94bz045y3bfz7m2r-source | 1 + .../8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source | 1 + .../a6m3cymd6cw5kz3zw6hxamd7cnb6mvjy-source | 1 + .../cjvwy2rr87ir1nb6wvs9n6lvbnzlqrdg-source | 1 + .../d334lhlj2amjdpl3np78lalp2f8c4d5c-source | 1 + .../d50vypw46l5rmmgz16hzg5r5r268ak2n-source | 1 + .../isia7synl0mdbcvfwav5ywnrwmwbwvxv-source | 1 + .../qjw6nq34h4s78573nh70gsl2a2qz76mz-source | 1 + .../r2ip1850igy8kciyaagw502s3c6ph1s4-source | 1 + .../xkci0s3glinkrb3prpz0ah6b8fg51504-source | 1 + .../yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source | 1 + .../yxld2qw84ka591fay1xkh5jflbgxjqa1-source | 1 + ...e-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa | 1 + ...5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc | 180 ++++++++++++++++++ .pre-commit-config.yaml | 1 + mapstructure.go | 2 +- reflect_go1_19.go | 9 + reflect_go1_20.go | 10 + 23 files changed, 237 insertions(+), 1 deletion(-) create mode 120000 .devenv/profile create mode 100755 .direnv/bin/nix-direnv-reload create mode 120000 .direnv/flake-inputs/027wnc7kfpdl7n7xr7pby8csjd31d8xw-source create mode 120000 .direnv/flake-inputs/2gkqfvzq2j0vbrlkx3y0k8qxyn4px989-source create mode 120000 .direnv/flake-inputs/4yg9rk38xim0166ynim8ndxvh6qi4pcc-source create mode 120000 .direnv/flake-inputs/88fpp9lrbs0vk8yf94bz045y3bfz7m2r-source create mode 120000 .direnv/flake-inputs/8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source create mode 120000 .direnv/flake-inputs/a6m3cymd6cw5kz3zw6hxamd7cnb6mvjy-source create mode 120000 .direnv/flake-inputs/cjvwy2rr87ir1nb6wvs9n6lvbnzlqrdg-source create mode 120000 .direnv/flake-inputs/d334lhlj2amjdpl3np78lalp2f8c4d5c-source create mode 120000 .direnv/flake-inputs/d50vypw46l5rmmgz16hzg5r5r268ak2n-source create mode 120000 .direnv/flake-inputs/isia7synl0mdbcvfwav5ywnrwmwbwvxv-source create mode 120000 .direnv/flake-inputs/qjw6nq34h4s78573nh70gsl2a2qz76mz-source create mode 120000 .direnv/flake-inputs/r2ip1850igy8kciyaagw502s3c6ph1s4-source create mode 120000 .direnv/flake-inputs/xkci0s3glinkrb3prpz0ah6b8fg51504-source create mode 120000 .direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source create mode 120000 .direnv/flake-inputs/yxld2qw84ka591fay1xkh5jflbgxjqa1-source create mode 120000 .direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa create mode 100644 .direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc create mode 120000 .pre-commit-config.yaml create mode 100644 reflect_go1_19.go create mode 100644 reflect_go1_20.go diff --git a/.devenv/profile b/.devenv/profile new file mode 120000 index 00000000..a9a53af5 --- /dev/null +++ b/.devenv/profile @@ -0,0 +1 @@ +/nix/store/7k68a83zyk7wzkjaa5kplgjqsyi4wpwd-devenv-profile \ No newline at end of file diff --git a/.direnv/bin/nix-direnv-reload b/.direnv/bin/nix-direnv-reload new file mode 100755 index 00000000..c9936f71 --- /dev/null +++ b/.direnv/bin/nix-direnv-reload @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -e +if [[ ! -d "/Users/mark/Projects/viper/mapstructure" ]]; then + echo "Cannot find source directory; Did you move it?" + echo "(Looking for "/Users/mark/Projects/viper/mapstructure")" + echo 'Cannot force reload with this script - use "direnv reload" manually and then try again' + exit 1 +fi + +# rebuild the cache forcefully +_nix_direnv_force_reload=1 direnv exec "/Users/mark/Projects/viper/mapstructure" true + +# Update the mtime for .envrc. +# This will cause direnv to reload again - but without re-building. +touch "/Users/mark/Projects/viper/mapstructure/.envrc" + +# Also update the timestamp of whatever profile_rc we have. +# This makes sure that we know we are up to date. +touch -r "/Users/mark/Projects/viper/mapstructure/.envrc" "/Users/mark/Projects/viper/mapstructure/.direnv"/*.rc diff --git a/.direnv/flake-inputs/027wnc7kfpdl7n7xr7pby8csjd31d8xw-source b/.direnv/flake-inputs/027wnc7kfpdl7n7xr7pby8csjd31d8xw-source new file mode 120000 index 00000000..ff0cfd66 --- /dev/null +++ b/.direnv/flake-inputs/027wnc7kfpdl7n7xr7pby8csjd31d8xw-source @@ -0,0 +1 @@ +/nix/store/027wnc7kfpdl7n7xr7pby8csjd31d8xw-source \ No newline at end of file diff --git a/.direnv/flake-inputs/2gkqfvzq2j0vbrlkx3y0k8qxyn4px989-source b/.direnv/flake-inputs/2gkqfvzq2j0vbrlkx3y0k8qxyn4px989-source new file mode 120000 index 00000000..894a8c7f --- /dev/null +++ b/.direnv/flake-inputs/2gkqfvzq2j0vbrlkx3y0k8qxyn4px989-source @@ -0,0 +1 @@ +/nix/store/2gkqfvzq2j0vbrlkx3y0k8qxyn4px989-source \ No newline at end of file diff --git a/.direnv/flake-inputs/4yg9rk38xim0166ynim8ndxvh6qi4pcc-source b/.direnv/flake-inputs/4yg9rk38xim0166ynim8ndxvh6qi4pcc-source new file mode 120000 index 00000000..9f814e2c --- /dev/null +++ b/.direnv/flake-inputs/4yg9rk38xim0166ynim8ndxvh6qi4pcc-source @@ -0,0 +1 @@ +/nix/store/4yg9rk38xim0166ynim8ndxvh6qi4pcc-source \ No newline at end of file diff --git a/.direnv/flake-inputs/88fpp9lrbs0vk8yf94bz045y3bfz7m2r-source b/.direnv/flake-inputs/88fpp9lrbs0vk8yf94bz045y3bfz7m2r-source new file mode 120000 index 00000000..800aae39 --- /dev/null +++ b/.direnv/flake-inputs/88fpp9lrbs0vk8yf94bz045y3bfz7m2r-source @@ -0,0 +1 @@ +/nix/store/88fpp9lrbs0vk8yf94bz045y3bfz7m2r-source \ No newline at end of file diff --git a/.direnv/flake-inputs/8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source b/.direnv/flake-inputs/8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source new file mode 120000 index 00000000..c2649c1f --- /dev/null +++ b/.direnv/flake-inputs/8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source @@ -0,0 +1 @@ +/nix/store/8sm7wycza5fl6lnsmw11sn4vqkvw4xyh-source \ No newline at end of file diff --git a/.direnv/flake-inputs/a6m3cymd6cw5kz3zw6hxamd7cnb6mvjy-source b/.direnv/flake-inputs/a6m3cymd6cw5kz3zw6hxamd7cnb6mvjy-source new file mode 120000 index 00000000..d5f4821d --- /dev/null +++ b/.direnv/flake-inputs/a6m3cymd6cw5kz3zw6hxamd7cnb6mvjy-source @@ -0,0 +1 @@ +/nix/store/a6m3cymd6cw5kz3zw6hxamd7cnb6mvjy-source \ No newline at end of file diff --git a/.direnv/flake-inputs/cjvwy2rr87ir1nb6wvs9n6lvbnzlqrdg-source b/.direnv/flake-inputs/cjvwy2rr87ir1nb6wvs9n6lvbnzlqrdg-source new file mode 120000 index 00000000..d177a31f --- /dev/null +++ b/.direnv/flake-inputs/cjvwy2rr87ir1nb6wvs9n6lvbnzlqrdg-source @@ -0,0 +1 @@ +/nix/store/cjvwy2rr87ir1nb6wvs9n6lvbnzlqrdg-source \ No newline at end of file diff --git a/.direnv/flake-inputs/d334lhlj2amjdpl3np78lalp2f8c4d5c-source b/.direnv/flake-inputs/d334lhlj2amjdpl3np78lalp2f8c4d5c-source new file mode 120000 index 00000000..60e86db4 --- /dev/null +++ b/.direnv/flake-inputs/d334lhlj2amjdpl3np78lalp2f8c4d5c-source @@ -0,0 +1 @@ +/nix/store/d334lhlj2amjdpl3np78lalp2f8c4d5c-source \ No newline at end of file diff --git a/.direnv/flake-inputs/d50vypw46l5rmmgz16hzg5r5r268ak2n-source b/.direnv/flake-inputs/d50vypw46l5rmmgz16hzg5r5r268ak2n-source new file mode 120000 index 00000000..9219af19 --- /dev/null +++ b/.direnv/flake-inputs/d50vypw46l5rmmgz16hzg5r5r268ak2n-source @@ -0,0 +1 @@ +/nix/store/d50vypw46l5rmmgz16hzg5r5r268ak2n-source \ No newline at end of file diff --git a/.direnv/flake-inputs/isia7synl0mdbcvfwav5ywnrwmwbwvxv-source b/.direnv/flake-inputs/isia7synl0mdbcvfwav5ywnrwmwbwvxv-source new file mode 120000 index 00000000..41f5b07e --- /dev/null +++ b/.direnv/flake-inputs/isia7synl0mdbcvfwav5ywnrwmwbwvxv-source @@ -0,0 +1 @@ +/nix/store/isia7synl0mdbcvfwav5ywnrwmwbwvxv-source \ No newline at end of file diff --git a/.direnv/flake-inputs/qjw6nq34h4s78573nh70gsl2a2qz76mz-source b/.direnv/flake-inputs/qjw6nq34h4s78573nh70gsl2a2qz76mz-source new file mode 120000 index 00000000..d3698b7c --- /dev/null +++ b/.direnv/flake-inputs/qjw6nq34h4s78573nh70gsl2a2qz76mz-source @@ -0,0 +1 @@ +/nix/store/qjw6nq34h4s78573nh70gsl2a2qz76mz-source \ No newline at end of file diff --git a/.direnv/flake-inputs/r2ip1850igy8kciyaagw502s3c6ph1s4-source b/.direnv/flake-inputs/r2ip1850igy8kciyaagw502s3c6ph1s4-source new file mode 120000 index 00000000..b1dabc8a --- /dev/null +++ b/.direnv/flake-inputs/r2ip1850igy8kciyaagw502s3c6ph1s4-source @@ -0,0 +1 @@ +/nix/store/r2ip1850igy8kciyaagw502s3c6ph1s4-source \ No newline at end of file diff --git a/.direnv/flake-inputs/xkci0s3glinkrb3prpz0ah6b8fg51504-source b/.direnv/flake-inputs/xkci0s3glinkrb3prpz0ah6b8fg51504-source new file mode 120000 index 00000000..3a912f12 --- /dev/null +++ b/.direnv/flake-inputs/xkci0s3glinkrb3prpz0ah6b8fg51504-source @@ -0,0 +1 @@ +/nix/store/xkci0s3glinkrb3prpz0ah6b8fg51504-source \ No newline at end of file diff --git a/.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source b/.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source new file mode 120000 index 00000000..f17959fc --- /dev/null +++ b/.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source @@ -0,0 +1 @@ +/nix/store/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source \ No newline at end of file diff --git a/.direnv/flake-inputs/yxld2qw84ka591fay1xkh5jflbgxjqa1-source b/.direnv/flake-inputs/yxld2qw84ka591fay1xkh5jflbgxjqa1-source new file mode 120000 index 00000000..a55cab58 --- /dev/null +++ b/.direnv/flake-inputs/yxld2qw84ka591fay1xkh5jflbgxjqa1-source @@ -0,0 +1 @@ +/nix/store/yxld2qw84ka591fay1xkh5jflbgxjqa1-source \ No newline at end of file diff --git a/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa new file mode 120000 index 00000000..ee69f1fa --- /dev/null +++ b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa @@ -0,0 +1 @@ +/nix/store/3g2mvqm72zsf7rsaffzf0snsl15b7b7m-devenv-shell-env \ No newline at end of file diff --git a/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc new file mode 100644 index 00000000..dfe8e72c --- /dev/null +++ b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc @@ -0,0 +1,180 @@ +unset shellHook +PATH=${PATH:-} +nix_saved_PATH="$PATH" +XDG_DATA_DIRS=${XDG_DATA_DIRS:-} +nix_saved_XDG_DATA_DIRS="$XDG_DATA_DIRS" +BASH='/nix/store/8rxm4jzw1dddm53rpc2zdqgafadn7d5n-bash-interactive-5.2-p21/bin/bash' +HOSTTYPE='aarch64' +IFS=' +' +IN_NIX_SHELL='impure' +export IN_NIX_SHELL +LINENO='76' +MACHTYPE='aarch64-apple-darwin22.6.0' +NIX_BUILD_CORES='0' +export NIX_BUILD_CORES +NIX_STORE='/nix/store' +export NIX_STORE +OLDPWD='' +export OLDPWD +OPTERR='1' +OSTYPE='darwin22.6.0' +PATH='/path-not-set' +export PATH +PS4='+ ' +builder='/nix/store/8rxm4jzw1dddm53rpc2zdqgafadn7d5n-bash-interactive-5.2-p21/bin/bash' +export builder +dontAddDisableDepTrack='1' +export dontAddDisableDepTrack +name='devenv-shell-env' +export name +out='/Users/mark/Projects/viper/mapstructure/outputs/out' +export out +outputs='out' +shellHook=' +# Remove all the unnecessary noise that is set by the build env +unset NIX_BUILD_TOP NIX_BUILD_CORES NIX_STORE +unset TEMP TEMPDIR TMP +# $name variable is preserved to keep it compatible with pure shell https://github.com/sindresorhus/pure/blob/47c0c881f0e7cfdb5eaccd335f52ad17b897c060/pure.zsh#L235 +unset builder out shellHook stdenv system +# Flakes stuff +unset dontAddDisableDepTrack outputs + +# For `nix develop`. We get /noshell on Linux and /sbin/nologin on macOS. +if [[ "$SHELL" == "/noshell" || "$SHELL" == "/sbin/nologin" ]]; then + export SHELL=/nix/store/8rxm4jzw1dddm53rpc2zdqgafadn7d5n-bash-interactive-5.2-p21/bin/bash +fi + +# https://github.com/numtide/devshell/issues/158 +PATH=${PATH#/path-not-set:} + +export DEVENV_PROFILE=/nix/store/7k68a83zyk7wzkjaa5kplgjqsyi4wpwd-devenv-profile + +# add installed packages to PATH +export PATH="$DEVENV_PROFILE/bin:$PATH" + +# prepend common compilation lookup paths +export PKG_CONFIG_PATH="$DEVENV_PROFILE/lib/pkgconfig:${PKG_CONFIG_PATH-}" +export LD_LIBRARY_PATH="$DEVENV_PROFILE/lib:${LD_LIBRARY_PATH-}" +export LIBRARY_PATH="$DEVENV_PROFILE/lib:${LIBRARY_PATH-}" +export C_INCLUDE_PATH="$DEVENV_PROFILE/include:${C_INCLUDE_PATH-}" + +# these provide shell completions / default config options +export XDG_DATA_DIRS="$DEVENV_PROFILE/share:${XDG_DATA_DIRS-}" +export XDG_CONFIG_DIRS="$DEVENV_PROFILE/etc/xdg:${XDG_CONFIG_DIRS-}" + +export DEVENV_DOTFILE='\''/Users/mark/Projects/viper/mapstructure/.devenv'\'' +export DEVENV_PROFILE='\''/nix/store/7k68a83zyk7wzkjaa5kplgjqsyi4wpwd-devenv-profile'\'' +export DEVENV_ROOT='\''/Users/mark/Projects/viper/mapstructure'\'' +export DEVENV_STATE='\''/Users/mark/Projects/viper/mapstructure/.devenv/state'\'' +export GOPATH='\''/Users/mark/Projects/viper/mapstructure/.devenv/state/go'\'' +export GOROOT='\''/nix/store/b0rpa34hn6cgbkbn8sfr5dzv723ia3z2-go-1.21.5/share/go/'\'' + +export PATH=/nix/store/zf05xsah3wfzcsb667ncxlj7xkgjpi20-pre-commit-3.3.3/bin:$PATH +if ! type -t git >/dev/null; then + # This happens in pure shells, including lorri + echo 1>&2 "WARNING: pre-commit-hooks.nix: git command not found; skipping installation." +elif ! /nix/store/q7avibx4c00h7zl3jfh3r5mc4xs6wsnj-git-2.42.0/bin/git rev-parse --git-dir &> /dev/null; then + echo 1>&2 "WARNING: pre-commit-hooks.nix: .git not found; skipping installation." +else + GIT_WC=`/nix/store/q7avibx4c00h7zl3jfh3r5mc4xs6wsnj-git-2.42.0/bin/git rev-parse --show-toplevel` + + # These update procedures compare before they write, to avoid + # filesystem churn. This improves performance with watch tools like lorri + # and prevents installation loops by via lorri. + + if readlink "${GIT_WC}/.pre-commit-config.yaml" >/dev/null \ + && [[ $(readlink "${GIT_WC}/.pre-commit-config.yaml") == /nix/store/3ws5xna2njkw8s4l002r5w80jrgq1wl9-pre-commit-config.json ]]; then + echo 1>&2 "pre-commit-hooks.nix: hooks up to date" + else + echo 1>&2 "pre-commit-hooks.nix: updating $PWD repo" + + [ -L .pre-commit-config.yaml ] && unlink .pre-commit-config.yaml + + if [ -e "${GIT_WC}/.pre-commit-config.yaml" ]; then + echo 1>&2 "pre-commit-hooks.nix: WARNING: Refusing to install because of pre-existing .pre-commit-config.yaml" + echo 1>&2 " 1. Translate .pre-commit-config.yaml contents to the new syntax in your Nix file" + echo 1>&2 " see https://github.com/cachix/pre-commit-hooks.nix#getting-started" + echo 1>&2 " 2. remove .pre-commit-config.yaml" + echo 1>&2 " 3. add .pre-commit-config.yaml to .gitignore" + else + ln -fs /nix/store/3ws5xna2njkw8s4l002r5w80jrgq1wl9-pre-commit-config.json "${GIT_WC}/.pre-commit-config.yaml" + # Remove any previously installed hooks (since pre-commit itself has no convergent design) + hooks="pre-commit pre-merge-commit pre-push prepare-commit-msg commit-msg post-checkout post-commit" + for hook in $hooks; do + pre-commit uninstall -t $hook + done + /nix/store/q7avibx4c00h7zl3jfh3r5mc4xs6wsnj-git-2.42.0/bin/git config --local core.hooksPath "" + # Add hooks for configured stages (only) ... + if [ ! -z "commit" ]; then + for stage in commit; do + if [[ "$stage" == "manual" ]]; then + continue + fi + case $stage in + # if you amend these switches please also review $hooks above + commit | merge-commit | push) + stage="pre-"$stage + pre-commit install -t $stage + ;; + prepare-commit-msg | commit-msg | post-checkout | post-commit) + pre-commit install -t $stage + ;; + *) + echo 1>&2 "ERROR: pre-commit-hooks.nix: either $stage is not a valid stage or pre-commit-hooks.nix doesn'\''t yet support it." + exit 1 + ;; + esac + done + # ... or default '\''pre-commit'\'' hook + else + pre-commit install + fi + /nix/store/q7avibx4c00h7zl3jfh3r5mc4xs6wsnj-git-2.42.0/bin/git config --local core.hooksPath "$(/nix/store/q7avibx4c00h7zl3jfh3r5mc4xs6wsnj-git-2.42.0/bin/git rev-parse --git-common-dir)/hooks" + fi + fi +fi + + +export PATH=$GOPATH/bin:$PATH + +export PS1="\[\e[0;34m\](devenv)\[\e[0m\] ${PS1-}" + +# set path to locales on non-NixOS Linux hosts + + +# note what environments are active, but make sure we don'\''t repeat them +if [[ ! "${DIRENV_ACTIVE-}" =~ (^|:)"$PWD"(:|$) ]]; then + export DIRENV_ACTIVE="$PWD:${DIRENV_ACTIVE-}" +fi + +# devenv helper +if [ ! type -p direnv &>/dev/null && -f .envrc ]; then + echo "You have .envrc but direnv command is not installed." + echo "Please install direnv: https://direnv.net/docs/installation.html" +fi + +mkdir -p .devenv +rm -f .devenv/profile +ln -s /nix/store/7k68a83zyk7wzkjaa5kplgjqsyi4wpwd-devenv-profile .devenv/profile + +' +export shellHook +stdenv='/nix/store/4dmdxaw0gzx9ns4n60kczbhsm0qlq3zz-naked-stdenv' +export stdenv +system='aarch64-darwin' +export system +runHook () +{ + + eval "$shellHook"; + unset runHook +} +PATH="$PATH${nix_saved_PATH:+:$nix_saved_PATH}" +XDG_DATA_DIRS="$XDG_DATA_DIRS${nix_saved_XDG_DATA_DIRS:+:$nix_saved_XDG_DATA_DIRS}" +export NIX_BUILD_TOP="$(mktemp -d -t nix-shell.XXXXXX)" +export TMP="$NIX_BUILD_TOP" +export TMPDIR="$NIX_BUILD_TOP" +export TEMP="$NIX_BUILD_TOP" +export TEMPDIR="$NIX_BUILD_TOP" +eval "$shellHook" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 120000 index 00000000..6beea463 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1 @@ +/nix/store/3ws5xna2njkw8s4l002r5w80jrgq1wl9-pre-commit-config.json \ No newline at end of file diff --git a/mapstructure.go b/mapstructure.go index 1f646317..d7ed4473 100644 --- a/mapstructure.go +++ b/mapstructure.go @@ -1163,7 +1163,7 @@ func (d *Decoder) decodeArray(name string, data interface{}, val reflect.Value) valArray := val - if valArray.Comparable() && valArray.Interface() == reflect.Zero(valArray.Type()).Interface() || d.config.ZeroFields { + if isComparable(valArray) && valArray.Interface() == reflect.Zero(valArray.Type()).Interface() || d.config.ZeroFields { // Check input type if dataValKind != reflect.Array && dataValKind != reflect.Slice { if d.config.WeaklyTypedInput { diff --git a/reflect_go1_19.go b/reflect_go1_19.go new file mode 100644 index 00000000..cee9bd37 --- /dev/null +++ b/reflect_go1_19.go @@ -0,0 +1,9 @@ +//go:build !go1.20 + +package mapstructure + +import "reflect" + +func isComparable(v reflect.Value) bool { + return false +} diff --git a/reflect_go1_20.go b/reflect_go1_20.go new file mode 100644 index 00000000..f8255a1b --- /dev/null +++ b/reflect_go1_20.go @@ -0,0 +1,10 @@ +//go:build go1.20 + +package mapstructure + +import "reflect" + +// TODO: remove once we drop support for Go <1.20 +func isComparable(v reflect.Value) bool { + return v.Comparable() +}