如何通过指针值从Golang的局部函数中获取变量?

Sorry I am pretty new to golang. I am struggling to understand the scope of variables. I tried to create a global variable to grab the variable out of the local function, however I keep getting an error that it has not been declared. I also tried to do a return statement, however I keep getting a syntax error of not having enough arguments and no return values.
I added something like func main() string { return Test2}
But I am doing something wrong, can't get my head around this issue

I tried creating a global variable to store the value outside the local function. I also tried to create a return function to grab the variable.

package main

import (
    "fmt"
    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/dynamodb"
)

var Test2 string

func main() {
    sess, _ := session.NewSession(&aws.Config{
        Region: aws.String("us-east-1")},
    )
    svc := dynamodb.New(sess)
    input := &dynamodb.GetItemInput{
        Key: map[string]*dynamodb.AttributeValue{
            "id": {
                S: aws.String("ami-xxxxx"),
            },
        },
        TableName: aws.String("table"),
    }

    result, _ := svc.GetItem(input)
    Test := result.Item["id"].S
    Test2 := *Test
    fmt.Println(Test2)

}

fmt.Println(Test2)

syntax error: non-declaration statement outside function body