Skip to content

Commit e1a0ba6

Browse files
committed
Merge branch 'santalla/devel'
2 parents c76f432 + 668e29a commit e1a0ba6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

generator/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,11 @@ func (m *Model) CtorArgs() string {
376376

377377
if paramsLen == i+1 && sig.Variadic() {
378378
typeName = "..." + typeName
379+
} else // TODO: Dirty fix for #229, address properly inside findableTypeName or typeString
380+
if collectionElemType(param.Type()) != nil && !strings.HasPrefix(typeName, "[]") {
381+
typeName = "[]" + typeName
379382
}
383+
380384
paramName := param.Name()
381385
if paramName == "s" {
382386
paramName = fmt.Sprintf("arg%v", i)

generator/types_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,11 @@ type User struct {
221221
Settings *Settings
222222
}
223223
224-
func newUser(id kallax.ULID, username, email string) (*User, error) {
224+
func newUser(id kallax.ULID, username, email string, websites []string) (*User, error) {
225225
if strings.Contains(email, "@spam.org") {
226226
return nil, errors.New("kallax: is spam!")
227227
}
228-
return &User{ID: id, Username: username, Email: email}, nil
228+
return &User{ID: id, Username: username, Email: email, Websites: websites}, nil
229229
}
230230
231231
type Email struct {
@@ -302,8 +302,8 @@ func (s *ModelSuite) TestModel() {
302302
}
303303

304304
func (s *ModelSuite) TestCtor() {
305-
s.Equal("id kallax.ULID, username string, email string", s.model.CtorArgs())
306-
s.Equal("id, username, email", s.model.CtorArgVars())
305+
s.Equal("id kallax.ULID, username string, email string, websites []string", s.model.CtorArgs())
306+
s.Equal("id, username, email, websites", s.model.CtorArgVars())
307307
s.Equal("(record *User, err error)", s.model.CtorReturns())
308308
s.Equal("record, err", s.model.CtorRetVars())
309309
}

0 commit comments

Comments
 (0)