#!/usr/bin/env bash# `go_toolchain` — the `go` that builds `cotton-whatsapp-link`, found the same# way by every script that needs it: `build-cotton-mac.sh`, which builds the# helper.## WHY A SEARCH AND NOT `command -v go` ALONE: a cut runs from a non-interactive# shell that never read the line Homebrew put in a profile, so `/opt/homebrew/bin`# can be missing from PATH on a Mac that has Go. CottonDB 0.29.24 shipped with no# WhatsApp helper because the build Mac had no Go at all; a PATH that merely misses the# Go that IS there must not do the same.## `COTTON_GO_SEARCH` (colon-separated directories) replaces the whole search,# PATH included — the guards use it to stand a Mac with no Go, or a fake one.## THIS IS A SOURCED SNIPPET. `go_toolchain` sets GO_BIN to the absolute path, or# leaves it empty and returns 1.go_toolchain() { GO_BIN=""local search="${COTTON_GO_SEARCH-${PATH:-}:/opt/homebrew/bin:/usr/local/go/bin:/usr/local/bin}"local dirlocal IFS=:for dir in $search; do [ -n "$dir" ] || continueif [ -f "$dir/go" ] && [ -x "$dir/go" ]; then GO_BIN="$dir/go"return0fidonereturn1}