Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling fmt.Printf("%v") on a DynamoDBAttributeValue causes mini-panic #205

Closed
keyneston opened this issue Jun 13, 2019 · 1 comment
Closed
Labels

Comments

@keyneston
Copy link

keyneston commented Jun 13, 2019

When you call fmt.Printf("%v") on any non-String events.DynamoDBAttributeValue a panic gets embedded into your string.

Example:

package main

import (
	"fmt"

	"github.com/aws/aws-lambda-go/events"
)

func main() {
	v := events.NewNumberAttribute("5")
	fmt.Println("This is a number: %v", v)
}

Outputs:

$ go run bugreport.go
This is a number: %v %!v(PANIC=String method: accessor called for incompatible type, requested type 8 but actual type was 5)

As far as I can tell this is due to the fact that you are using .String() as the function to get back a string from the attribute. This conflicts with the fact that .String() is also the interface used for printing.

av.ensureType(DataTypeNumberSet)

@bmoffatt
Copy link
Collaborator

Merged #226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants