# Issue with timestamps when porting JavaScript CloudQuery plugin to Golang

**URL:** <https://community.cloudquery.io/t/issue-with-timestamps-when-porting-javascript-cloudquery-plugin-to-golang/253>\
**Category:** CloudQuery Plugins\
**Created:** [April 13, 2024, 12:11am UTC](https://community.cloudquery.io/t/issue-with-timestamps-when-porting-javascript-cloudquery-plugin-to-golang/253 "2024-04-13T00:11:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pro-mastiff](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@pro-mastiff](https://community.cloudquery.io/u/pro-mastiff)\
**Post date:** [April 13, 2024, 12:11am UTC](https://community.cloudquery.io/t/issue-with-timestamps-when-porting-javascript-cloudquery-plugin-to-golang/253/1 "2024-04-13T00:11:58Z")

</div>

Hey team, I’m a JavaScript developer who has successfully written several plugins using the JS SDK. However, I’m currently trying to port them over to Golang since there aren’t enough examples and docs for JS for things like incremental tables.

That being said, I’m getting stuck on minor things since I’ve never developed in Go before. My latest issue is with timestamps. I have a column `created` and its value is `2023-02-24T18:51:07`. In JavaScript, for the column, I just specify:

```javascript
createColumn({
      name: 'created',
      type: new Timestamp(TimeUnit.SECOND),
      resolver: pathResolver('created'),
}),

```

But in Go, when I try to use:

```go
{
    Name: "created",
    Type: arrow.FixedWidthTypes.Timestamp_s,
    Resolver: schema.PathResolver("created"),
},

```

It’s always null upon syncing. I’ve also tried all the other fixed-width type `timestamp_*` with no luck.

JavaScript works, Golang is null.

---

<div class="post-metadata">

**Author:** ![erez](https://sea1.discourse-cdn.com/flex001/user_avatar/community.cloudquery.io/erez/32/40_2.png) [@erez](https://community.cloudquery.io/u/erez)\
**Post date:** [April 13, 2024, 12:59pm UTC](https://community.cloudquery.io/t/issue-with-timestamps-when-porting-javascript-cloudquery-plugin-to-golang/253/2 "2024-04-13T12:59:44Z")

</div>

Hi @pro-mastiff,

We would love to hear more about your usage of the JS SDK, as it might encourage us to add incremental table support. 🙂

As for the migration to Go, you might need

```go
schema.PathResolver("Created")

```

as in Go `PathResolver` works on struct fields properties which are capital case.

---

<div class="post-metadata">

**Author:** ![pro-mastiff](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@pro-mastiff](https://community.cloudquery.io/u/pro-mastiff)\
**Post date:** [April 13, 2024, 1:09pm UTC](https://community.cloudquery.io/t/issue-with-timestamps-when-porting-javascript-cloudquery-plugin-to-golang/253/3 "2024-04-13T13:09:09Z")

</div>

I gave capital case a shot but no dice. FWIW, all the other columns I have are lowercase in the `pathResolver` because they’re lowercase in the JSON and they all work. I’m wondering if it’s because the timestamp doesn’t have a time zone on it. JavaScript is often more forgiving when it comes to that.

Might try a custom resolver to append a `Z` at the end to see if that allows it to be synced correctly.

---

<div class="post-metadata">

**Author:** ![erez](https://sea1.discourse-cdn.com/flex001/user_avatar/community.cloudquery.io/erez/32/40_2.png) [@erez](https://community.cloudquery.io/u/erez)\
**Post date:** [April 13, 2024, 2:03pm UTC](https://community.cloudquery.io/t/issue-with-timestamps-when-porting-javascript-cloudquery-plugin-to-golang/253/4 "2024-04-13T14:03:43Z")

</div>

Maybe you could share some code that should help debug the issue.

This is the relevant code for Go’s path resolver: [resolvers.go](https://github.com/cloudquery/plugin-sdk/blob/9e4f78e9a3939584e2ef3c3210c07c6677d8aec9/schema/resolvers.go#L17). You can see it works on the struct fields.

Can you share the type of the struct with its fields? If you think the issue is time zone related, you could try using a string type and see if that solves it.

The conversion from the value received in the response happens here: [timestamp.go](https://github.com/cloudquery/plugin-sdk/blob/9e4f78e9a3939584e2ef3c3210c07c6677d8aec9/scalar/timestamp.go#L57). You can see some examples of supported values here: [timestamp\_test.go](https://github.com/cloudquery/plugin-sdk/blob/9e4f78e9a3939584e2ef3c3210c07c6677d8aec9/scalar/timestamp_test.go#L25).

---

<div class="post-metadata">

**Author:** ![pro-mastiff](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@pro-mastiff](https://community.cloudquery.io/u/pro-mastiff)\
**Post date:** [April 15, 2024, 5:31pm UTC](https://community.cloudquery.io/t/issue-with-timestamps-when-porting-javascript-cloudquery-plugin-to-golang/253/5 "2024-04-15T17:31:25Z")

</div>

I’ve confirmed it’s because of the format of the timestamp string. Appending “Z” to the end does allow it to parse correctly. I’ve asked the maintainers of the API I’m consuming via my plugin to format the timestamp with the appropriate time zone.

```auto
time.ParseError {Layout: "2006-01-02T15:04:05Z07:00", Value: "2023-02-24T18:51:07", LayoutElem: "Z07:00", ValueElem: "", Message: ""}

```

For whatever reason, timezone is not required in JavaScript for parsing.

---

<div class="post-metadata">

**Author:** ![erez](https://sea1.discourse-cdn.com/flex001/user_avatar/community.cloudquery.io/erez/32/40_2.png) [@erez](https://community.cloudquery.io/u/erez)\
**Post date:** [April 15, 2024, 5:43pm UTC](https://community.cloudquery.io/t/issue-with-timestamps-when-porting-javascript-cloudquery-plugin-to-golang/253/6 "2024-04-15T17:43:43Z")

</div>

I think [this line](https://github.com/cloudquery/plugin-sdk-javascript/blob/bbcccbc712037e04f4275039c7880cbe2deba0db/src/scalar/timestamp.ts#L57) could be the reason.  
Thanks for following up with the solution.
