Created
February 13, 2015 13:13
-
-
Save mpfund/c3d39ca07d04c36cb2f3 to your computer and use it in GitHub Desktop.
Golang gomaz aws, dynamodb PutItem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "github.com/AdRoll/goamz/aws" | |
| "github.com/AdRoll/goamz/dynamodb" | |
| "log" | |
| "strings" | |
| ) | |
| func main() { | |
| auth, _ := aws.EnvAuth() | |
| nv := aws.NeverRetryPolicy{} | |
| ddbs := dynamodb.Server{auth, aws.USEast, nv} | |
| response, err := ddbs.ListTables() | |
| pkattr := dynamodb.NewStringAttribute("Url", "") | |
| pk := dynamodb.PrimaryKey{pkattr, nil} | |
| table := dynamodb.Table{&ddbs, "urls", pk} | |
| k := dynamodb.NewStringAttribute("Test", "test") | |
| ok, err := table.PutItem("http://google.com", "", []dynamodb.Attribute{*k}) | |
| fmt.Println(ok) | |
| if err != nil { | |
| log.Fatal(err.Error()) | |
| } | |
| fmt.Printf("The tablenames are %s!", strings.Join(response, ", ")) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment