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

Cannot generate dataloader with target type 'time.Time' #54

Open
vanjiii opened this issue Nov 30, 2020 · 0 comments · May be fixed by #55
Open

Cannot generate dataloader with target type 'time.Time' #54

vanjiii opened this issue Nov 30, 2020 · 0 comments · May be fixed by #55

Comments

@vanjiii
Copy link

vanjiii commented Nov 30, 2020

What I am trying to do:

Generate a dataloader with target type time.Time. Example given: //go:generate dataloaden fooLoader int *time.Time

What happen:

Generating fails with:

➜  go-test go generate ./...                                                                                                                                                                             16:31:36
validation failed: packages.Load: /home/vanjiii/dev/src/junk/go-test/fooloader_gen.go:9:2: time redeclared in this block
/home/vanjiii/dev/src/junk/go-test/fooloader_gen.go:7:2:        other declaration of time
exit status 1
main.go:10: running "go": exit status 1

The generated file fooloader_gen.go

// Code generated by github.com/vektah/dataloaden, DO NOT EDIT.

package main

import (
	"sync"
	"time"

	"time"
)
// rest of file...

What is expected

The generation to complete.

Workaround

  • Create a wrapper type:
type Time struct {
    time.Time
}
  • Generate the dataloader with the newly created type:
    //go:generate dataloaden fooLoader int *Time
@vanjiii vanjiii linked a pull request Dec 1, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant