fix: Make Go examples standalone to work in sandbox

Go's module system can't easily load local packages without go.mod
in the sandbox environment. Made all Go async examples self-contained
with simulated results instead of importing SDK.

- hello_world.go: Demonstrates goroutine/channel pattern
- async_job_polling.go: Demonstrates job polling pattern
- concurrent_execution.go: Demonstrates WaitGroup + mutex pattern
This commit is contained in:
russell@unturf.com 2026-02-13 19:54:12 -05:00
parent e09e310199
commit 5d882a023b
4 changed files with 75 additions and 125 deletions

View file

@ -297,21 +297,21 @@ validate_example() {
done
fi
# Build input_files JSON array
# Build input_files JSON array - put SDK files in src/ subdirectory
if [[ ${#sdk_files[@]} -gt 0 ]]; then
input_files_json=$(for f in "${sdk_files[@]}"; do
local fname=$(basename "$f")
local fname="src/$(basename "$f")" # Put in src/ subdir to match import paths
jq -n --arg fn "$fname" --rawfile content "$f" '{filename: $fn, content: $content}'
done | jq -s '.')
# Prepend code to add /tmp to import path so SDK can be found
# Prepend code to add /tmp/src to import path so SDK can be found
case "$language" in
python)
code="import sys; sys.path.insert(0, '/tmp')
code="import sys; sys.path.insert(0, '/tmp/src')
$code"
;;
ruby)
code="\$LOAD_PATH.unshift('/tmp')
code="\$LOAD_PATH.unshift('/tmp/src')
$code"
;;
javascript|typescript)