steering_docs/go-tech/hello.md
šØ CRITICAL - Must be completed BEFORE any code generation
# Step 1: List available knowledge bases
ListKnowledgeBases()
# Step 2: Query coding standards (REQUIRED)
QueryKnowledgeBases("coding-standards-KB", "Go-code-example-standards")
# Step 3: Query implementation patterns (REQUIRED)
QueryKnowledgeBases("Go-premium-KB", "Go implementation patterns")
# Step 4: AWS service research (REQUIRED)
search_documentation("What is [AWS Service] and what are its key API operations?")
read_documentation("https://docs.aws.amazon.com/[service]/latest/[relevant-page]")
FAILURE TO COMPLETE KNOWLEDGE BASE CONSULTATION WILL RESULT IN INCORRECT CODE STRUCTURE
Generate simple "Hello" examples that demonstrate basic service connectivity and the most fundamental operation using direct AWS SDK for Go v2 client calls.
gov2/{service}/hello/
āāā hello.go # MANDATORY: Hello example file
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Package main demonstrates basic {AWS Service} connectivity.
package main
import (
"context"
"errors"
"fmt"
"log"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/{service}"
"github.com/aws/smithy-go"
)
// main demonstrates basic {AWS Service} connectivity by {basic operation description}.
func main() {
ctx := context.Background()
// Load AWS configuration
sdkConfig, err := config.LoadDefaultConfig(ctx)
if err != nil {
log.Fatalf("Couldn't load default configuration: %v", err)
}
// Create service client
{service}Client := {service}.NewFromConfig(sdkConfig)
// Perform the most basic operation for this service
result, err := {service}Client.{BasicOperation}(ctx, &{service}.{BasicOperationInput}{
// Add minimal required parameters if any
})
if err != nil {
var ae smithy.APIError
if errors.As(err, &ae) {
switch ae.ErrorCode() {
case "UnauthorizedOperation", "AccessDenied":
fmt.Println("You don't have permission to access {AWS Service}.")
default:
fmt.Printf("Couldn't access {AWS Service}. Error: %v\n", err)
}
} else {
fmt.Printf("Couldn't access {AWS Service}. Error: %v\n", err)
}
return
}
fmt.Println("Hello, {AWS Service}!")
// Display appropriate result information based on service type
}
result, err := s3Client.ListBuckets(ctx, &s3.ListBucketsInput{})
if err != nil {
// Handle error
}
fmt.Printf("Found %d bucket(s):\n", len(result.Buckets))
for _, bucket := range result.Buckets {
fmt.Printf(" %s\n", *bucket.Name)
}
result, err := guarddutyClient.ListDetectors(ctx, &guardduty.ListDetectorsInput{})
if err != nil {
// Handle error
}
fmt.Printf("Found %d detector(s)\n", len(result.DetectorIds))
result, err := ec2Client.DescribeRegions(ctx, &ec2.DescribeRegionsInput{})
if err != nil {
// Handle error
}
fmt.Printf("Found %d region(s):\n", len(result.Regions))
for _, region := range result.Regions {
fmt.Printf(" %s\n", *region.RegionName)
}
// Standard error handling for hello examples
if err != nil {
var ae smithy.APIError
if errors.As(err, &ae) {
switch ae.ErrorCode() {
case "UnauthorizedOperation", "AccessDenied":
fmt.Println("You don't have permission to access {AWS Service}.")
case "InvalidUserID.NotFound":
fmt.Println("User credentials not found or invalid.")
default:
fmt.Printf("Couldn't access {AWS Service}. Error: %v\n", err)
}
} else {
fmt.Printf("Couldn't access {AWS Service}. Error: %v\n", err)
}
return
}
// Always use context for AWS operations
ctx := context.Background()
// For operations with timeout (if needed)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
result, err := client.Operation(ctx, &service.OperationInput{
// Parameters
})
{service}.NewFromConfig(sdkConfig) to create clientsgov2/{service}/hello/hello.gopackage mainmain() function as entry point