EventStore-Client-Go icon indicating copy to clipboard operation
EventStore-Client-Go copied to clipboard

correctness of ContentTypeJson value

Open karthiksedoc opened this issue 1 year ago • 2 comments

Looks like the following:

	eventData := esdb.EventData{
		ContentType: esdb.ContentTypeJson,
		EventType:   "TestEvent",
		Data:        data,
	}

in https://github.com/EventStore/EventStore-Client-Go/blob/c29aa7d3ce9c0aadc7d2bfa3dd060f2865efb227/samples/quickstart.go#L42C21-L42C36 is incorrect , does it have to be int as in below?

https://github.com/EventStore/EventStore-Client-Go/blob/c29aa7d3ce9c0aadc7d2bfa3dd060f2865efb227/esdb/event_data.go#L12

the following code works for me:

	eventData := esdb.EventData {
		ContentType: 1,
		EventType: "TestEvent",
		Data: data,
	}

So, the ContentType: esdb.ContentTypeJson need to be changed to ContentType: 1 ?

karthiksedoc avatar Dec 06 '24 11:12 karthiksedoc

Hey @karthiksedoc,

I'm a bit confused by your question. See esdb.ContentTypeJson is a regular integer as shown at its declaration site.

https://github.com/EventStore/EventStore-Client-Go/blob/v4.2.0/esdb/event_data.go

So it is normal to be able to use either 1 or esdb.ContentTypeJson.

YoEight avatar Dec 06 '24 15:12 YoEight

Hey @karthiksedoc,

I'm a bit confused by your question. See esdb.ContentTypeJson is a regular integer as shown at its declaration site.

https://github.com/EventStore/EventStore-Client-Go/blob/v4.2.0/esdb/event_data.go

So it is normal to be able to use either 1 or esdb.ContentTypeJson.

Thanks for getting back to me @YoEight 👍 . I might be not setting it properly:

When I set:

        eventData := esdb.EventData {
                ContentType: esdb.ContentTypeJson,
                EventType: "TestEvent",
                Data: data,
        }

I get the follow:

➜  gorpc_test git:(main) go build main.go 
# command-line-arguments
./main.go:42:21: undefined: esdb.ContentTypeJson

the build works without error when setting:

	eventData := esdb.EventData {
		ContentType: 1,
		EventType: "TestEvent",
		Data: data,
	}

I was following the example and encountered this 🙇

karthiksedoc avatar Dec 09 '24 11:12 karthiksedoc