Commit 83f789c1 authored by Dmitry Smirnov's avatar Dmitry Smirnov

Imported Upstream version 1.0.7+dfsg

parent bbdb97c7
......@@ -6,9 +6,16 @@ go:
- 1.4
- 1.5
- tip
# Use Go 1.5's vendoring experiment for 1.5 tests. 1.4 tests will use the tip of the dependancies repo.
install: "go get -v -t ./... && make deps"
script: make unit
- make get-deps
- make unit
LINTIGNOREDOT='internal/features.+should not use dot imports'
LINTIGNOREDOC='service/[^/]+/(api|service)\.go:.+(comment on exported|should have comment or be unexported)'
LINTIGNORECONST='service/[^/]+/(api|service)\.go:.+(type|struct field|const|func) ([^ ]+) should be ([^ ]+)'
LINTIGNOREDOT='awstesting/integration.+should not use dot imports'
LINTIGNOREDOC='service/[^/]+/(api|service|waiters)\.go:.+(comment on exported|should have comment or be unexported)'
LINTIGNORECONST='service/[^/]+/(api|service|waiters)\.go:.+(type|struct field|const|func) ([^ ]+) should be ([^ ]+)'
LINTIGNORESTUTTER='service/[^/]+/(api|service)\.go:.+(and that stutters)'
LINTIGNOREINFLECT='service/[^/]+/(api|service)\.go:.+method .+ should be '
SDK_WITH_VENDOR_PKGS=$(shell go list ./... | grep -v "/vendor/src")
SDK_ONLY_PKGS=$(shell go list ./... | grep -v "/vendor/")
all: generate unit
@echo "Please use \`make <target>' where <target> is one of"
@echo " api_info to print a list of services and versions"
@echo " build to go build the SDK"
@echo " deps to go get the SDK dependencies"
@echo " docs to build SDK documentation"
@echo " generate to go generate and make services"
@echo " generate-protocol-test to generate protocol tests"
@echo " build to go build the SDK"
@echo " unit to run unit tests"
@echo " integration to run integration tests"
@echo " verify to verify tests"
@echo " lint to lint the SDK"
@echo " services to generate services"
@echo " unit to run unit tests"
@echo " vet to vet the SDK"
@echo " generate to go generate and make services"
@echo " gen-test to generate protocol tests"
@echo " gen-services to generate services"
@echo " get-deps to go get the SDK dependencies"
@echo " get-deps-unit to get the SDK's unit test dependencies"
@echo " get-deps-integ to get the SDK's integration test dependencies"
@echo " get-deps-verify to get the SDK's verification dependencies"
default: generate
generate: gen-test gen-endpoints gen-services
go generate ./internal/protocol/...
gen-test: gen-protocol-test
generate-test: generate-protocol-test
go generate ./service
go generate ./internal/endpoints
@make services
go generate ./private/protocol/...
go generate ./service
go generate ./private/endpoints
@echo "go build SDK and vendor packages"
unit: get-deps-unit build verify
@echo "go test SDK and vendor packages"
integration: get-deps-integ
go test -tags=integration ./awstesting/integration/customizations/...
gucumber ./awstesting/integration/smoke
integration: deps
go test ./internal/test/integration/... -tags=integration
gucumber ./internal/features/smoke
verify: get-deps-verify lint vet
lint: deps
@echo "golint ./..."
@echo "go lint SDK and vendor packages"
@lint=`golint ./...`; \
lint=`echo "$$lint" | grep -E -v -e ${LINTIGNOREDOT} -e ${LINTIGNOREDOC} -e ${LINTIGNORECONST}`; \
echo "$$lint"; \
if [ "$$lint" != "" ]; then exit 1; fi
unit: deps build lint
go test ./...
go tool vet -all -shadow $(shell ls -d */ | grep -v vendor)
go build ./...
get-deps: get-deps-unit get-deps-integ get-deps-verify
@echo "go get SDK dependencies"
@go get -v $(SDK_ONLY_PKGS)
@echo "go get SDK unit testing dependancies"
go get
go get
get-deps-integ: get-deps-unit
@echo "go get SDK integration testing dependencies"
go get
@echo "go get SDK verification utilities"
go get
@echo "go bench SDK packages"
@go test -run NONE -bench . -benchmem -tags 'bench' $(SDK_ONLY_PKGS)
@echo "go bench SDK protocol marshallers"
@go test -run NONE -bench . -benchmem -tags 'bench' ./private/protocol/...
@echo "generate SDK docs"
rm -rf doc && bundle install && bundle exec yard
@go get ./...
@go get
@go get
@go run internal/model/cli/api-info/api-info.go
@go test -bench . -benchmem -tags 'perf' ./internal/test/perf/...
\ No newline at end of file
@go run private/model/cli/api-info/api-info.go
......@@ -9,31 +9,13 @@ aws-sdk-go is the official AWS SDK for the Go programming language.
Checkout our [release notes]( for information about the latest bug fixes, updates, and features added to the SDK.
**Release [v0.9.0rc1]( introduced a breaking change to the SDK. See the release notes for details of the change and instructions to migrate to the latest SDK version.**
## Caution
The SDK is currently in the process of being developed, and not everything
may be working fully yet. Please be patient and report any bugs or problems
you experience. The APIs may change radically without much warning, so please
vendor your dependencies with Godep or similar.
Please do not confuse this for a stable, feature-complete library.
Note that while most AWS protocols are currently supported, not all services
available in this package are implemented fully, as some require extra
customizations to work with the SDK. If you've encountered such a scenario,
please open a [GitHub issue](
so we can track work for the service.
## Installing
Install your specific service package with the following `go get` command.
For example, EC2 support might be installed with:
If you are using Go 1.5 with the `GO15VENDOREXPERIMENT=1` vendoring flag you can use the following to get the SDK as the SDK's runtime dependancies are vendored in the `vendor` folder.
$ go get
$ go get -u
You can also install the entire SDK by installing the root package, including all of the SDK's dependencies:
Otherwise you'll need to tell Go to get the SDK and all of its dependancies.
$ go get -u
......@@ -59,10 +41,10 @@ AWS_ACCESS_KEY_ID=AKID1234567890
## Using
## Using the Go SDK
To use a service in the SDK, create a service variable by calling the `New()`
function. Once you have a service, you can call API operations which each
function. Once you have a service client, you can call API operations which each
return response data and a possible error.
To list a set of instance IDs from EC2, you could run:
......@@ -74,6 +56,7 @@ import (
......@@ -81,7 +64,7 @@ func main() {
// Create an EC2 service object in the "us-west-2" region
// Note that you can also configure your region globally by
// exporting the AWS_REGION environment variable
svc := ec2.New(&aws.Config{Region: aws.String("us-west-2")})
svc := ec2.New(session.New(), &aws.Config{Region: aws.String("us-west-2")})
// Call the DescribeInstances Operation
resp, err := svc.DescribeInstances(nil)
This diff is collapsed.
......@@ -57,16 +57,13 @@ func rcopy(dst, src reflect.Value, root bool) {
case reflect.Struct:
if !root {
t := dst.Type()
for i := 0; i < t.NumField(); i++ {
name := t.Field(i).Name
srcval := src.FieldByName(name)
if srcval.IsValid() {
rcopy(dst.FieldByName(name), srcval, false)
srcVal := src.FieldByName(name)
dstVal := dst.FieldByName(name)
if srcVal.IsValid() && dstVal.CanSet() {
rcopy(dstVal, srcVal, false)
case reflect.Slice:
......@@ -77,6 +77,28 @@ func TestCopy(t *testing.T) {
assert.NotEqual(t, f2.C, f1.C)
func TestCopyNestedWithUnexported(t *testing.T) {
type Bar struct {
a int
B int
type Foo struct {
A string
B Bar
f1 := &Foo{A: "string", B: Bar{a: 1, B: 2}}
var f2 Foo
awsutil.Copy(&f2, f1)
// Values match
assert.Equal(t, f2.A, f1.A)
assert.NotEqual(t, f2.B, f1.B)
assert.NotEqual(t, f2.B.a, f1.B.a)
assert.Equal(t, f2.B.B, f2.B.B)
func TestCopyIgnoreNilMembers(t *testing.T) {
type Foo struct {
A *string
......@@ -136,6 +158,8 @@ func TestCopyDifferentStructs(t *testing.T) {
C map[string]*int
SrcUnique string
SameNameDiffType int
unexportedPtr *int
ExportedPtr *int
type DstFoo struct {
A int
......@@ -143,6 +167,8 @@ func TestCopyDifferentStructs(t *testing.T) {
C map[string]*int
DstUnique int
SameNameDiffType string
unexportedPtr *int
ExportedPtr *int
// Create the initial value
......@@ -159,6 +185,8 @@ func TestCopyDifferentStructs(t *testing.T) {
SrcUnique: "unique",
SameNameDiffType: 1,
unexportedPtr: &int1,
ExportedPtr: &int2,
// Do the copy
......@@ -173,6 +201,10 @@ func TestCopyDifferentStructs(t *testing.T) {
assert.Equal(t, 1, f1.SameNameDiffType)
assert.Equal(t, 0, f2.DstUnique)
assert.Equal(t, "", f2.SameNameDiffType)
assert.Equal(t, int1, *f1.unexportedPtr)
assert.Nil(t, f2.unexportedPtr)
assert.Equal(t, int2, *f1.ExportedPtr)
assert.Equal(t, int2, *f2.ExportedPtr)
func ExampleCopyOf() {
package awsutil
import (
// DeepEqual returns if the two values are deeply equal like reflect.DeepEqual.
// In addition to this, this method will also dereference the input values if
// possible so the DeepEqual performed will not fail if one parameter is a
// pointer and the other is not.
// DeepEqual will not perform indirection of nested values of the input parameters.
func DeepEqual(a, b interface{}) bool {
ra := reflect.Indirect(reflect.ValueOf(a))
rb := reflect.Indirect(reflect.ValueOf(b))
if raValid, rbValid := ra.IsValid(), rb.IsValid(); !raValid && !rbValid {
// If the elements are both nil, and of the same type the are equal
// If they are of different types they are not equal
return reflect.TypeOf(a) == reflect.TypeOf(b)
} else if raValid != rbValid {
// Both values must be valid to be equal
return false
return reflect.DeepEqual(ra.Interface(), rb.Interface())