Skip to content

Commit

Permalink
EXAMPLES.md: fix example for struct field pointer update
Browse files Browse the repository at this point in the history
  • Loading branch information
dgryski committed Apr 4, 2024
1 parent 7ad7d3a commit c696075
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ package main
import (
"fmt"
"log"
"os"
"os"

"github.com/fastly/go-fastly/v9/fastly"
)

Expand Down Expand Up @@ -46,7 +47,7 @@ func main() {
// then we'll clone from whatever is the latest version.
latest := service.Versions[len(service.Versions)-1]
for _, version := range service.Versions {
if version.Active {
if *version.Active {
latest = version
break
}
Expand All @@ -56,7 +57,7 @@ func main() {
// active configuration.
version, err := client.CloneVersion(&fastly.CloneVersionInput{
ServiceID: serviceID,
ServiceVersion: latest.Number,
ServiceVersion: *latest.Number,
})
if err != nil {
log.Fatal(err)
Expand All @@ -66,8 +67,8 @@ func main() {
// a new domain.
domain, err := client.CreateDomain(&fastly.CreateDomainInput{
ServiceID: serviceID,
ServiceVersion: version.Number,
Name: fastly.String("example.com"),
ServiceVersion: *version.Number,
Name: fastly.ToPointer("example.com"),
})
if err != nil {
log.Fatal(err)
Expand All @@ -79,10 +80,10 @@ func main() {
// And we will also add a new backend.
backend, err := client.CreateBackend(&fastly.CreateBackendInput{
ServiceID: serviceID,
ServiceVersion: version.Number,
Name: fastly.String("example-backend"),
Address: fastly.String("127.0.0.1"),
Port: fastly.Int(80),
ServiceVersion: *version.Number,
Name: fastly.ToPointer("example-backend"),
Address: fastly.ToPointer("127.0.0.1"),
Port: fastly.ToPointer(80),
})
if err != nil {
log.Fatal(err)
Expand All @@ -94,7 +95,7 @@ func main() {
// Now we can validate that our version is valid.
valid, _, err := client.ValidateVersion(&fastly.ValidateVersionInput{
ServiceID: serviceID,
ServiceVersion: version.Number,
ServiceVersion: *version.Number,
})
if err != nil {
log.Fatal(err)
Expand All @@ -106,7 +107,7 @@ func main() {
// Finally, activate this new version.
activeVersion, err := client.ActivateVersion(&fastly.ActivateVersionInput{
ServiceID: serviceID,
ServiceVersion: version.Number,
ServiceVersion: *version.Number,
})
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit c696075

Please sign in to comment.