Skip to content

Commit d1ece7c

Browse files
committed
refactor(go-snippets): Unify Go module structure and dynamically update ADK dependency
Consolidate all Go snippet module dependencies to a single file located at . This simplifies dependency management and ensures consistent versions across all Go examples. Update Usage: tools/go-snippets/runner.sh <build|run> [file1 file2 ...] to dynamically fetch the latest module () before running any builds or tests. This ensures that PR and regression checks always validate against the most recent ADK release, preventing outdated dependency issues. Address breaking changes in by removing the initialization from , which is no longer available. Cleaned up extraneous and files from subdirectories within , as well as the unused file.
1 parent f76b10d commit d1ece7c

File tree

4 files changed

+29
-35
lines changed

4 files changed

+29
-35
lines changed

examples/go/go.mod

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module snippets
33
go 1.25.1
44

55
require (
6-
google.golang.org/adk v0.1.0
6+
google.golang.org/adk v0.2.0
77
google.golang.org/genai v1.35.0
88
)
99

@@ -19,6 +19,7 @@ require (
1919
github.com/google/go-cmp v0.7.0 // indirect
2020
github.com/google/jsonschema-go v0.3.0 // indirect
2121
github.com/google/s2a-go v0.1.9 // indirect
22+
github.com/google/safehtml v0.1.0 // indirect
2223
github.com/google/uuid v1.6.0 // indirect
2324
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
2425
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
@@ -31,11 +32,12 @@ require (
3132
go.opentelemetry.io/otel/metric v1.38.0 // indirect
3233
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
3334
go.opentelemetry.io/otel/trace v1.38.0 // indirect
34-
golang.org/x/crypto v0.43.0 // indirect
35-
golang.org/x/net v0.46.0 // indirect
36-
golang.org/x/sync v0.17.0 // indirect
37-
golang.org/x/sys v0.37.0 // indirect
38-
golang.org/x/text v0.30.0 // indirect
35+
golang.org/x/crypto v0.45.0 // indirect
36+
golang.org/x/net v0.47.0 // indirect
37+
golang.org/x/sync v0.18.0 // indirect
38+
golang.org/x/sys v0.38.0 // indirect
39+
golang.org/x/text v0.31.0 // indirect
40+
google.golang.org/genproto/googleapis/api v0.0.0-20251014184007-4626949a642f // indirect
3941
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f // indirect
4042
google.golang.org/grpc v1.76.0 // indirect
4143
google.golang.org/protobuf v1.36.10 // indirect

examples/go/go.sum

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ github.com/google/jsonschema-go v0.3.0 h1:6AH2TxVNtk3IlvkkhjrtbUc4S8AvO0Xii0DxIy
2525
github.com/google/jsonschema-go v0.3.0/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE=
2626
github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=
2727
github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=
28+
github.com/google/safehtml v0.1.0 h1:EwLKo8qawTKfsi0orxcQAZzu07cICaBeFMegAU9eaT8=
29+
github.com/google/safehtml v0.1.0/go.mod h1:L4KWwDsUJdECRAEpZoBn3O64bQaywRscowZjJAzjHnU=
2830
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
2931
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
3032
github.com/googleapis/enterprise-certificate-proxy v0.3.6 h1:GW/XbdyBFQ8Qe+YAmFU9uHLo7OnF5tL52HFAgMmyrf4=
@@ -57,23 +59,24 @@ go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJr
5759
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
5860
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
5961
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
60-
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
61-
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
62-
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
63-
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
64-
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
65-
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
66-
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
67-
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
68-
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
69-
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
62+
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
63+
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
64+
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
65+
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
66+
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
67+
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
68+
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
69+
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
70+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
71+
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
72+
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
73+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
7074
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
7175
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
72-
google.golang.org/adk v0.1.0 h1:+w/fHuqRVolotOATlujRA+2DKUuDrFH2poRdEX2QjB8=
73-
google.golang.org/adk v0.1.0/go.mod h1:NvtSLoNx7UzZIiUAI1KoJQLMmt9sG3oCgiCx1TLqKFw=
76+
google.golang.org/adk v0.2.0 h1:X+iAZ2uiJMtOp8sbevcPtnVpTQmymaeN6qsVnBKmJ/s=
77+
google.golang.org/adk v0.2.0/go.mod h1:Nl15krF+mrvl/kCXOy+haxquJwSpLLbsKGScqCwkn60=
7478
google.golang.org/genai v1.35.0 h1:Jo6g25CzVqFzGrX5mhWyBgQqXAUzxcx5jeK7U74zv9c=
7579
google.golang.org/genai v1.35.0/go.mod h1:A3kkl0nyBjyFlNjgxIwKq70julKbIxpSxqKO5gw/gmk=
76-
google.golang.org/genproto v0.0.0-20251014184007-4626949a642f h1:vLd1CJuJOUgV6qijD7KT5Y2ZtC97ll4dxjTUappMnbo=
7780
google.golang.org/genproto/googleapis/api v0.0.0-20251014184007-4626949a642f h1:OiFuztEyBivVKDvguQJYWq1yDcfAHIID/FVrPR4oiI0=
7881
google.golang.org/genproto/googleapis/api v0.0.0-20251014184007-4626949a642f/go.mod h1:kprOiu9Tr0JYyD6DORrc4Hfyk3RFXqkQ3ctHEum3ZbM=
7982
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f h1:1FTH6cpXFsENbPR5Bu8NQddPSaUUE6NA2XdZdDSAJK4=

examples/go/snippets/sessions/session_management_example/session_management_example.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,6 @@ func main() {
3737
inMemoryService := session.InMemoryService()
3838
fmt.Println("Initialized InMemoryService.")
3939

40-
// --8<-- [start:vertexai_service]
41-
// 2. VertexAIService
42-
// Before running, ensure your environment is authenticated:
43-
// gcloud auth application-default login
44-
// export GOOGLE_CLOUD_PROJECT="your-gcp-project-id"
45-
// export GOOGLE_CLOUD_LOCATION="your-gcp-location"
46-
modelName := "gemini-1.5-flash-001" // Replace with your desired model
47-
vertexService, err := session.VertexAIService(ctx, modelName)
48-
if err != nil {
49-
log.Printf("Could not initialize VertexAIService (this is expected if the gcloud project is not set): %v", err)
50-
} else {
51-
fmt.Println("Successfully initialized VertexAIService.")
52-
}
53-
// --8<-- [end:vertexai_service]
54-
_ = vertexService // Avoid unused variable error if initialization fails.
55-
5640
// --- Examining Session Properties ---
5741
// We'll use the InMemoryService for this demonstration.
5842
// --8<-- [start:examine_session]

tools/go-snippets/runner.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
128128
ACTION=$1
129129
shift # Remove the first argument, so '$@' contains only the file paths.
130130

131+
# Update to the latest version of the ADK.
132+
# This ensures that we are always testing against the most recent release.
133+
echo "Updating google.golang.org/adk to latest..."
134+
(cd examples/go && go get google.golang.org/adk@latest)
135+
131136
# Ensure all Go module dependencies are tidy before running any builds or tests.
132137
# This is run from the 'examples/go' directory where the go.mod file is located.
133138
(cd examples/go && go mod tidy)

0 commit comments

Comments
 (0)