Skip to content

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

Closed
@keyneston

Description

@keyneston

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions