Skip to content

Commit 75c1e17

Browse files
use downloaded libraries and Go module
1 parent 30b8bc5 commit 75c1e17

5 files changed

Lines changed: 20 additions & 21 deletions

File tree

go-tui/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ ditto-tasks-termui
22
go-tui
33
*.log
44
*.out
5+
go-sdk/

go-tui/Makefile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,33 @@ ARCH := $(shell uname -m)
2323

2424
# Determine Ditto SDK platform string
2525
ifeq ($(PLATFORM),linux)
26-
DITTO_PLATFORM = go-linux-$(ARCH)
26+
DITTO_PLATFORM = linux-$(ARCH)
2727
else ifeq ($(PLATFORM),darwin)
28-
DITTO_PLATFORM = go-macos-aarch64
28+
DITTO_PLATFORM = macos-aarch64
29+
30+
# avoid version mismatch warnings when linking
31+
export MACOSX_DEPLOYMENT_TARGET := 11.0
32+
export CGO_CFLAGS := -mmacosx-version-min=11.0
33+
export CGO_LDFLAGS := -mmacosx-version-min=11.0
2934
else
3035
$(error Unsupported platform: $(PLATFORM))
3136
endif
3237

33-
DITTO_SDK_URL = https://software.ditto.live/$(DITTO_PLATFORM)/Ditto/$(DITTO_SDK_VERSION)/dist/Ditto.tar.gz
38+
DITTO_SDK_URL = https://software.ditto.live/go-$(DITTO_PLATFORM)/Ditto/$(DITTO_SDK_VERSION)/libs/libdittoffi-$(DITTO_PLATFORM).tar.gz
3439

3540
# Build the application
3641
.PHONY: build
3742
build: go-sdk ditto-tasks-termui
3843

3944
ditto-tasks-termui:
4045
@echo "Building ditto-tasks-termui..."
41-
$(GO) build -o ditto-tasks-termui
46+
$(GO) mod tidy
47+
$(GO) build -o ditto-tasks-termui -ldflags='-extldflags "-L./go-sdk"'
4248

4349
.PHONY: go-sdk
4450
go-sdk: ## Downloads and installs the Ditto Go SDK library to go-sdk directory
45-
@if [ ! -f go-sdk/libdittoffi.so ] && [ ! -f go-sdk/libdittoffi.dylib ] ; then \
46-
@echo "📥 Downloading Ditto Go SDK v$(DITTO_SDK_VERSION) for $(DITTO_PLATFORM)..."
51+
@ if [ ! -f go-sdk/libdittoffi.so ] && [ ! -f go-sdk/libdittoffi.dylib ] ; then \
52+
echo "📥 Downloading Ditto Go SDK v$(DITTO_SDK_VERSION) for $(DITTO_PLATFORM) $(DITTO_SDK_URL)..."; \
4753
mkdir -p go-sdk; \
4854
if curl -L -f $(DITTO_SDK_URL) | tar xz --strip-components=0 -C go-sdk/; then \
4955
echo "✅ Ditto Go SDK v$(DITTO_SDK_VERSION) installed successfully"; \
@@ -55,20 +61,20 @@ go-sdk: ## Downloads and installs the Ditto Go SDK library to go-sdk directory
5561
fi
5662

5763
# Run the application (built binary)
58-
.PHONY: BUILD_TYPE
64+
.PHONY: build
5965
run: build
6066
@echo "Running ditto-tasks-termui..."
61-
LD_LIBRARY_PATH="$(pwd)/go-sdk" DYLD_LIBRARY_PATH="$(pwd)/go-sdk" ./ditto-tasks-termui 2>/dev/null
67+
LD_LIBRARY_PATH="$$(pwd)/go-sdk" DYLD_LIBRARY_PATH="$$(pwd)/go-sdk" ./ditto-tasks-termui 2>/dev/null
6268

6369
# Run directly with Go
6470
.PHONY: run-go
6571
run-go:
6672
@echo "Running ditto tasks-termui with go run..."
67-
LD_LIBRARY_PATH="$(pwd)/go-sdk" DYLD_LIBRARY_PATH="$(pwd)/go-sdk" $(GO) run main.go 2>/dev/null
73+
LD_LIBRARY_PATH="$$(pwd)/go-sdk" DYLD_LIBRARY_PATH="$$(pwd)/go-sdk" $(GO) run main.go 2>/dev/null
6874

6975
# Clean build artifacts
7076
.PHONY: clean
7177
clean:
7278
@echo "Cleaning ditto-tasks-termui and build artifacts..."
7379
rm -f ditto-tasks-termui
74-
rm -f go-sdk
80+
rm -rf go-sdk

go-tui/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module github.com/getditto/quickstart/go-tui/ditto-tasks-termui
22

3-
go 1.23
3+
go 1.24.0
44

55
require (
6-
github.com/getditto/ditto-go-sdk v5.0.0-go-preview.1
6+
github.com/getditto/ditto-go-sdk/v5 v5.0.0
77
github.com/gizak/termui/v3 v3.1.0
88
github.com/google/uuid v1.6.0
99
github.com/joho/godotenv v1.5.1

go-tui/go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
31
github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE=
42
github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
53
github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc=
@@ -15,18 +13,12 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzC
1513
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
1614
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840=
1715
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
18-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
19-
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2016
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
2117
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
2218
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
23-
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
24-
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
2519
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
2620
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
2721
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
2822
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
2923
golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ=
3024
golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA=
31-
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
32-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

go-tui/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12-
"github.com/getditto/ditto-go-sdk/ditto"
12+
"github.com/getditto/ditto-go-sdk/v5/ditto"
1313
ui "github.com/gizak/termui/v3"
1414
"github.com/gizak/termui/v3/widgets"
1515
"github.com/google/uuid"

0 commit comments

Comments
 (0)