When i try to access the struct field i got an error
invalid memory address or nil pointer dereference. gdreport/main.go:30 +0x1e6
i have no clue about the error:
here is my code:
var strPtr []*string
var findingId []string = []string{"findingid"}
strPtr = aws.StringSlice(findingId)
maxResult := int64(8)
condition := map[string]*guardduty.Condition{}
condition["id"].Equals = strPtr
line 30 condition["id"].Equals = strPtr
aws sdk for golang https://docs.aws.amazon.com/sdk-for-go/api/service/guardduty/#Condition type
Because
conditionis the emptymapofpointers, you getnilvalue of*guardduty.Conditionfromcondition.According Go maps in action:
Change your code snippet to