status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
β | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
timestamp[us, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | q := r.q.Select("withObject")
q = q.Arg("object", object)
return &Module{
q: q,
c: r.c,
}
}
type ModuleConfig struct {
q *querybuilder.Selection
c graphql.Client
name *string
root *string
sdk *string
}
func (r *ModuleConfig) Dependencies(ctx context.Context) ([]string, error) {
q := r.q.Select("dependencies")
var response []string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *ModuleConfig) Exclude(ctx context.Context) ([]string, error) {
q := r.q.Select("exclude")
var response []string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *ModuleConfig) Include(ctx context.Context) ([]string, error) {
q := r.q.Select("include")
var response []string
q = q.Bind(&response) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | return response, q.Execute(ctx, r.c)
}
func (r *ModuleConfig) Name(ctx context.Context) (string, error) {
if r.name != nil {
return *r.name, nil
}
q := r.q.Select("name")
var response string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *ModuleConfig) Root(ctx context.Context) (string, error) {
if r.root != nil {
return *r.root, nil
}
q := r.q.Select("root")
var response string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *ModuleConfig) SDK(ctx context.Context) (string, error) {
if r.sdk != nil {
return *r.sdk, nil
}
q := r.q.Select("sdk")
var response string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
type ObjectTypeDef struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | q *querybuilder.Selection
c graphql.Client
description *string
name *string
}
func (r *ObjectTypeDef) Description(ctx context.Context) (string, error) {
if r.description != nil {
return *r.description, nil
}
q := r.q.Select("description")
var response string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *ObjectTypeDef) Fields(ctx context.Context) ([]FieldTypeDef, error) {
q := r.q.Select("fields")
q = q.Select("description name")
type fields struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | Description string
Name string
}
convert := func(fields []fields) []FieldTypeDef {
out := []FieldTypeDef{}
for i := range fields {
val := FieldTypeDef{description: &fields[i].Description, name: &fields[i].Name}
out = append(out, val)
}
return out
}
var response []fields
q = q.Bind(&response)
err := q.Execute(ctx, r.c)
if err != nil {
return nil, err
}
return convert(response), nil
}
func (r *ObjectTypeDef) Functions(ctx context.Context) ([]Function, error) {
q := r.q.Select("functions")
q = q.Select("id")
type functions struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | Id FunctionID
}
convert := func(fields []functions) []Function {
out := []Function{}
for i := range fields {
val := Function{id: &fields[i].Id}
val.q = querybuilder.Query().Select("loadFunctionFromID").Arg("id", fields[i].Id)
val.c = r.c
out = append(out, val)
}
return out
}
var response []functions
q = q.Bind(&response)
err := q.Execute(ctx, r.c)
if err != nil {
return nil, err
}
return convert(response), nil
}
func (r *ObjectTypeDef) Name(ctx context.Context) (string, error) {
if r.name != nil {
return *r.name, nil
}
q := r.q.Select("name")
var response string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
type Port struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | q *querybuilder.Selection
c graphql.Client
description *string
port *int
protocol *NetworkProtocol
}
func (r *Port) Description(ctx context.Context) (string, error) {
if r.description != nil {
return *r.description, nil
}
q := r.q.Select("description")
var response string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *Port) Port(ctx context.Context) (int, error) {
if r.port != nil {
return *r.port, nil
}
q := r.q.Select("port")
var response int
q = q.Bind(&response)
return response, q.Execute(ctx, r.c) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | }
func (r *Port) Protocol(ctx context.Context) (NetworkProtocol, error) {
if r.protocol != nil {
return *r.protocol, nil
}
q := r.q.Select("protocol")
var response NetworkProtocol
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
type WithClientFunc func(r *Client) *Client
func (r *Client) With(f WithClientFunc) *Client {
return f(r)
}
func (r *Client) CacheVolume(key string) *CacheVolume {
q := r.q.Select("cacheVolume")
q = q.Arg("key", key)
return &CacheVolume{
q: q,
c: r.c,
}
}
func (r *Client) CheckVersionCompatibility(ctx context.Context, version string) (bool, error) {
q := r.q.Select("checkVersionCompatibility")
q = q.Arg("version", version)
var response bool
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
type ContainerOpts struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | ID ContainerID
Platform Platform
}
func (r *Client) Container(opts ...ContainerOpts) *Container {
q := r.q.Select("container")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].ID) {
q = q.Arg("id", opts[i].ID)
}
if !querybuilder.IsZeroValue(opts[i].Platform) {
q = q.Arg("platform", opts[i].Platform)
}
}
return &Container{
q: q,
c: r.c,
}
}
func (r *Client) CurrentFunctionCall() *FunctionCall {
q := r.q.Select("currentFunctionCall")
return &FunctionCall{
q: q,
c: r.c, |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | }
}
func (r *Client) CurrentModule() *Module {
q := r.q.Select("currentModule")
return &Module{
q: q,
c: r.c,
}
}
func (r *Client) DefaultPlatform(ctx context.Context) (Platform, error) {
q := r.q.Select("defaultPlatform")
var response Platform
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
type DirectoryOpts struct {
ID DirectoryID
}
func (r *Client) Directory(opts ...DirectoryOpts) *Directory {
q := r.q.Select("directory")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].ID) {
q = q.Arg("id", opts[i].ID)
}
}
return &Directory{
q: q,
c: r.c,
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | }
func (r *Client) File(id FileID) *File {
q := r.q.Select("file")
q = q.Arg("id", id)
return &File{
q: q,
c: r.c,
}
}
func (r *Client) Function(name string, returnType *TypeDef) *Function {
assertNotNil("returnType", returnType)
q := r.q.Select("function")
q = q.Arg("name", name)
q = q.Arg("returnType", returnType)
return &Function{
q: q,
c: r.c,
}
}
func (r *Client) GeneratedCode(code *Directory) *GeneratedCode {
assertNotNil("code", code)
q := r.q.Select("generatedCode")
q = q.Arg("code", code)
return &GeneratedCode{
q: q,
c: r.c,
}
}
type GitOpts struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | KeepGitDir bool
ExperimentalServiceHost *Service
}
func (r *Client) Git(url string, opts ...GitOpts) *GitRepository {
q := r.q.Select("git")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].KeepGitDir) {
q = q.Arg("keepGitDir", opts[i].KeepGitDir)
}
if !querybuilder.IsZeroValue(opts[i].ExperimentalServiceHost) {
q = q.Arg("experimentalServiceHost", opts[i].ExperimentalServiceHost)
}
}
q = q.Arg("url", url)
return &GitRepository{
q: q,
c: r.c,
}
}
func (r *Client) Host() *Host {
q := r.q.Select("host")
return &Host{
q: q,
c: r.c,
}
}
type HTTPOpts struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | ExperimentalServiceHost *Service
}
func (r *Client) HTTP(url string, opts ...HTTPOpts) *File {
q := r.q.Select("http")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].ExperimentalServiceHost) {
q = q.Arg("experimentalServiceHost", opts[i].ExperimentalServiceHost)
}
}
q = q.Arg("url", url)
return &File{
q: q,
c: r.c,
}
}
func (r *Client) LoadCacheVolumeFromID(id CacheVolumeID) *CacheVolume {
q := r.q.Select("loadCacheVolumeFromID")
q = q.Arg("id", id)
return &CacheVolume{
q: q,
c: r.c,
}
}
func (r *Client) LoadContainerFromID(id ContainerID) *Container {
q := r.q.Select("loadContainerFromID")
q = q.Arg("id", id)
return &Container{
q: q, |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | c: r.c,
}
}
func (r *Client) LoadDirectoryFromID(id DirectoryID) *Directory {
q := r.q.Select("loadDirectoryFromID")
q = q.Arg("id", id)
return &Directory{
q: q,
c: r.c,
}
}
func (r *Client) LoadFileFromID(id FileID) *File {
q := r.q.Select("loadFileFromID")
q = q.Arg("id", id)
return &File{
q: q,
c: r.c,
}
}
func (r *Client) LoadFunctionArgFromID(id FunctionArgID) *FunctionArg {
q := r.q.Select("loadFunctionArgFromID")
q = q.Arg("id", id)
return &FunctionArg{
q: q,
c: r.c,
}
}
func (r *Client) LoadFunctionFromID(id FunctionID) *Function {
q := r.q.Select("loadFunctionFromID")
q = q.Arg("id", id) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | return &Function{
q: q,
c: r.c,
}
}
func (r *Client) LoadGeneratedCodeFromID(id GeneratedCodeID) *GeneratedCode {
q := r.q.Select("loadGeneratedCodeFromID")
q = q.Arg("id", id)
return &GeneratedCode{
q: q,
c: r.c,
}
}
func (r *Client) LoadModuleFromID(id ModuleID) *Module {
q := r.q.Select("loadModuleFromID")
q = q.Arg("id", id)
return &Module{
q: q,
c: r.c,
}
}
func (r *Client) LoadSecretFromID(id SecretID) *Secret {
q := r.q.Select("loadSecretFromID")
q = q.Arg("id", id)
return &Secret{
q: q,
c: r.c,
}
}
func (r *Client) LoadServiceFromID(id ServiceID) *Service { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | q := r.q.Select("loadServiceFromID")
q = q.Arg("id", id)
return &Service{
q: q,
c: r.c,
}
}
func (r *Client) LoadSocketFromID(id SocketID) *Socket {
q := r.q.Select("loadSocketFromID")
q = q.Arg("id", id)
return &Socket{
q: q,
c: r.c,
}
}
func (r *Client) LoadTypeDefFromID(id TypeDefID) *TypeDef {
q := r.q.Select("loadTypeDefFromID")
q = q.Arg("id", id)
return &TypeDef{
q: q,
c: r.c,
}
}
func (r *Client) Module() *Module {
q := r.q.Select("module")
return &Module{
q: q,
c: r.c,
}
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | type ModuleConfigOpts struct {
Subpath string
}
func (r *Client) ModuleConfig(sourceDirectory *Directory, opts ...ModuleConfigOpts) *ModuleConfig {
assertNotNil("sourceDirectory", sourceDirectory)
q := r.q.Select("moduleConfig")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].Subpath) {
q = q.Arg("subpath", opts[i].Subpath)
}
}
q = q.Arg("sourceDirectory", sourceDirectory)
return &ModuleConfig{
q: q,
c: r.c,
}
}
type PipelineOpts struct {
Description string
Labels []PipelineLabel
}
func (r *Client) Pipeline(name string, opts ...PipelineOpts) *Client {
q := r.q.Select("pipeline")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].Description) {
q = q.Arg("description", opts[i].Description) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | }
if !querybuilder.IsZeroValue(opts[i].Labels) {
q = q.Arg("labels", opts[i].Labels)
}
}
q = q.Arg("name", name)
return &Client{
q: q,
c: r.c,
}
}
func (r *Client) Secret(id SecretID) *Secret {
q := r.q.Select("secret")
q = q.Arg("id", id)
return &Secret{
q: q,
c: r.c,
}
}
func (r *Client) SetSecret(name string, plaintext string) *Secret {
q := r.q.Select("setSecret")
q = q.Arg("name", name)
q = q.Arg("plaintext", plaintext)
return &Secret{
q: q,
c: r.c,
}
}
type SocketOpts struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | ID SocketID
}
func (r *Client) Socket(opts ...SocketOpts) *Socket {
q := r.q.Select("socket")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].ID) {
q = q.Arg("id", opts[i].ID)
}
}
return &Socket{
q: q,
c: r.c,
}
}
func (r *Client) TypeDef() *TypeDef {
q := r.q.Select("typeDef")
return &TypeDef{
q: q,
c: r.c,
}
}
type Secret struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | q *querybuilder.Selection
c graphql.Client
id *SecretID
plaintext *string
}
func (r *Secret) ID(ctx context.Context) (SecretID, error) {
if r.id != nil {
return *r.id, nil
}
q := r.q.Select("id")
var response SecretID
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *Secret) XXX_GraphQLType() string {
return "Secret"
}
func (r *Secret) XXX_GraphQLIDType() string {
return "SecretID"
}
func (r *Secret) XXX_GraphQLID(ctx context.Context) (string, error) {
id, err := r.ID(ctx)
if err != nil {
return "", err
}
return string(id), nil
}
func (r *Secret) MarshalJSON() ([]byte, error) {
id, err := r.ID(context.Background()) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | if err != nil {
return nil, err
}
return json.Marshal(id)
}
func (r *Secret) Plaintext(ctx context.Context) (string, error) {
if r.plaintext != nil {
return *r.plaintext, nil
}
q := r.q.Select("plaintext")
var response string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
type Service struct {
q *querybuilder.Selection
c graphql.Client
endpoint *string
hostname *string
id *ServiceID
start *ServiceID
stop *ServiceID
}
type ServiceEndpointOpts struct {
Port int
Scheme string
}
func (r *Service) Endpoint(ctx context.Context, opts ...ServiceEndpointOpts) (string, error) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | if r.endpoint != nil {
return *r.endpoint, nil
}
q := r.q.Select("endpoint")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].Port) {
q = q.Arg("port", opts[i].Port)
}
if !querybuilder.IsZeroValue(opts[i].Scheme) {
q = q.Arg("scheme", opts[i].Scheme)
}
}
var response string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *Service) Hostname(ctx context.Context) (string, error) {
if r.hostname != nil {
return *r.hostname, nil
}
q := r.q.Select("hostname")
var response string
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *Service) ID(ctx context.Context) (ServiceID, error) {
if r.id != nil {
return *r.id, nil |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | }
q := r.q.Select("id")
var response ServiceID
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *Service) XXX_GraphQLType() string {
return "Service"
}
func (r *Service) XXX_GraphQLIDType() string {
return "ServiceID"
}
func (r *Service) XXX_GraphQLID(ctx context.Context) (string, error) {
id, err := r.ID(ctx)
if err != nil {
return "", err
}
return string(id), nil
}
func (r *Service) MarshalJSON() ([]byte, error) {
id, err := r.ID(context.Background())
if err != nil {
return nil, err
}
return json.Marshal(id)
}
func (r *Service) Ports(ctx context.Context) ([]Port, error) {
q := r.q.Select("ports")
q = q.Select("description port protocol")
type ports struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | Description string
Port int
Protocol NetworkProtocol
}
convert := func(fields []ports) []Port {
out := []Port{}
for i := range fields {
val := Port{description: &fields[i].Description, port: &fields[i].Port, protocol: &fields[i].Protocol}
out = append(out, val)
}
return out
}
var response []ports
q = q.Bind(&response)
err := q.Execute(ctx, r.c)
if err != nil {
return nil, err
}
return convert(response), nil
}
func (r *Service) Start(ctx context.Context) (*Service, error) {
q := r.q.Select("start")
return r, q.Execute(ctx, r.c)
}
func (r *Service) Stop(ctx context.Context) (*Service, error) {
q := r.q.Select("stop")
return r, q.Execute(ctx, r.c)
}
type Socket struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | q *querybuilder.Selection
c graphql.Client
id *SocketID
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | func (r *Socket) ID(ctx context.Context) (SocketID, error) {
if r.id != nil {
return *r.id, nil
}
q := r.q.Select("id")
var response SocketID
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *Socket) XXX_GraphQLType() string {
return "Socket"
}
func (r *Socket) XXX_GraphQLIDType() string {
return "SocketID"
}
func (r *Socket) XXX_GraphQLID(ctx context.Context) (string, error) {
id, err := r.ID(ctx)
if err != nil {
return "", err
}
return string(id), nil
}
func (r *Socket) MarshalJSON() ([]byte, error) {
id, err := r.ID(context.Background())
if err != nil {
return nil, err
}
return json.Marshal(id)
}
type TypeDef struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | q *querybuilder.Selection
c graphql.Client
id *TypeDefID
kind *TypeDefKind
optional *bool
}
type WithTypeDefFunc func(r *TypeDef) *TypeDef
func (r *TypeDef) With(f WithTypeDefFunc) *TypeDef {
return f(r)
}
func (r *TypeDef) AsList() *ListTypeDef {
q := r.q.Select("asList")
return &ListTypeDef{
q: q,
c: r.c,
}
}
func (r *TypeDef) AsObject() *ObjectTypeDef {
q := r.q.Select("asObject")
return &ObjectTypeDef{
q: q,
c: r.c,
}
}
func (r *TypeDef) ID(ctx context.Context) (TypeDefID, error) {
if r.id != nil {
return *r.id, nil
}
q := r.q.Select("id")
var response TypeDefID |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
func (r *TypeDef) XXX_GraphQLType() string {
return "TypeDef"
}
func (r *TypeDef) XXX_GraphQLIDType() string {
return "TypeDefID"
}
func (r *TypeDef) XXX_GraphQLID(ctx context.Context) (string, error) {
id, err := r.ID(ctx)
if err != nil {
return "", err
}
return string(id), nil
}
func (r *TypeDef) MarshalJSON() ([]byte, error) {
id, err := r.ID(context.Background())
if err != nil {
return nil, err
}
return json.Marshal(id)
}
func (r *TypeDef) Kind(ctx context.Context) (TypeDefKind, error) {
if r.kind != nil {
return *r.kind, nil
}
q := r.q.Select("kind")
var response TypeDefKind
q = q.Bind(&response) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | return response, q.Execute(ctx, r.c)
}
func (r *TypeDef) Optional(ctx context.Context) (bool, error) {
if r.optional != nil {
return *r.optional, nil
}
q := r.q.Select("optional")
var response bool
q = q.Bind(&response)
return response, q.Execute(ctx, r.c)
}
type TypeDefWithFieldOpts struct {
Description string
}
func (r *TypeDef) WithField(name string, typeDef *TypeDef, opts ...TypeDefWithFieldOpts) *TypeDef {
assertNotNil("typeDef", typeDef)
q := r.q.Select("withField")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].Description) {
q = q.Arg("description", opts[i].Description)
}
}
q = q.Arg("name", name)
q = q.Arg("typeDef", typeDef)
return &TypeDef{
q: q,
c: r.c,
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | }
func (r *TypeDef) WithFunction(function *Function) *TypeDef {
assertNotNil("function", function)
q := r.q.Select("withFunction")
q = q.Arg("function", function)
return &TypeDef{
q: q,
c: r.c,
}
}
func (r *TypeDef) WithKind(kind TypeDefKind) *TypeDef {
q := r.q.Select("withKind")
q = q.Arg("kind", kind)
return &TypeDef{
q: q,
c: r.c,
}
}
func (r *TypeDef) WithListOf(elementType *TypeDef) *TypeDef {
assertNotNil("elementType", elementType)
q := r.q.Select("withListOf")
q = q.Arg("elementType", elementType)
return &TypeDef{
q: q,
c: r.c,
}
}
type TypeDefWithObjectOpts struct {
Description string
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | func (r *TypeDef) WithObject(name string, opts ...TypeDefWithObjectOpts) *TypeDef {
q := r.q.Select("withObject")
for i := len(opts) - 1; i >= 0; i-- {
if !querybuilder.IsZeroValue(opts[i].Description) {
q = q.Arg("description", opts[i].Description)
}
}
q = q.Arg("name", name)
return &TypeDef{
q: q,
c: r.c,
}
}
func (r *TypeDef) WithOptional(optional bool) *TypeDef {
q := r.q.Select("withOptional")
q = q.Arg("optional", optional)
return &TypeDef{
q: q,
c: r.c,
}
}
type CacheSharingMode string
func (CacheSharingMode) IsEnum() {}
const (
Locked CacheSharingMode = "LOCKED"
Private CacheSharingMode = "PRIVATE"
Shared CacheSharingMode = "SHARED"
)
type ImageLayerCompression string |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,864 | Zenith: Fix `Opts` types in Go SDK | From @jedevc:
---
Looks like `Opt` types can't be pointers, e.g. something like this doesn't work:
```go
type EchoOpts struct {
Suffix string `doc:"String to append to the echoed message." default:"..."`
Times int `doc:"Number of times to repeat the message." default:"3"`
}
func (m *Minimal) EchoOpts(msg string, opts *EchoOpts) string {
return m.EchoOptsInline(msg, opts)
}
```
The arg type needs to be changed to `opts EchoOpts` for it to work as intended.
Giving:
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1809: Undefined type EchoOptsID.
```
---
`Opts` structs cannot be nested:
```go
package main
import "fmt"
type Potato struct{}
type PotatoOptions struct {
Count int
TestingOptions TestingOptions
}
type TestingOptions struct {
Foo string
}
func (m *Potato) HelloWorld(opts PotatoOptions) string {
return fmt.Sprintf("Hello world, I have %d potatoes (%s)", opts.Count, opts.TestingOptions.Foo)
}
```
```
Error: failed to get loaded module ID: input:1: host.directory.asModule.serve failed to install module schema: schema validation failed: input:1803: Undefined type TestingOptionsID.
``` | https://github.com/dagger/dagger/issues/5864 | https://github.com/dagger/dagger/pull/5907 | db901c8fe4c70cc32336e304492ca37f12b8f389 | e8ad5c62275172e3d54ae46447e741ff5d603450 | 2023-10-10T22:55:05Z | go | 2023-10-25T19:38:59Z | sdk/go/dagger.gen.go | func (ImageLayerCompression) IsEnum() {}
const (
Estargz ImageLayerCompression = "EStarGZ"
Gzip ImageLayerCompression = "Gzip"
Uncompressed ImageLayerCompression = "Uncompressed"
Zstd ImageLayerCompression = "Zstd"
)
type ImageMediaTypes string
func (ImageMediaTypes) IsEnum() {}
const (
Dockermediatypes ImageMediaTypes = "DockerMediaTypes"
Ocimediatypes ImageMediaTypes = "OCIMediaTypes"
)
type NetworkProtocol string
func (NetworkProtocol) IsEnum() {}
const (
Tcp NetworkProtocol = "TCP"
Udp NetworkProtocol = "UDP"
)
type TypeDefKind string
func (TypeDefKind) IsEnum() {}
const (
Booleankind TypeDefKind = "BooleanKind"
Integerkind TypeDefKind = "IntegerKind"
Listkind TypeDefKind = "ListKind"
Objectkind TypeDefKind = "ObjectKind"
Stringkind TypeDefKind = "StringKind"
Voidkind TypeDefKind = "VoidKind"
) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | package templates
import (
"encoding/json"
"fmt"
"go/ast"
"go/token"
"go/types"
"path/filepath"
"sort"
"strings"
. "github.com/dave/jennifer/jen"
"github.com/iancoleman/strcase"
"golang.org/x/tools/go/packages"
)
const (
daggerGenFilename = "dagger.gen.go"
contextTypename = "context.Context"
)
/* TODO:
* Handle types from 3rd party imports in the type signature
* Add packages.NeedImports and packages.NeedDependencies to packages.Load opts, ensure performance is okay (or deal with that by lazy loading)
* Fix problem where changing a function signature requires running `dagger mod sync` twice (first one will result in package errors being seen, second one fixes)
* Use Overlays field in packages.Config to provide partial generation of dagger.gen.go, without the unupdated code we generate here
* Handle automatically re-running `dagger mod sync` when invoking functions from CLI, to save users from having to always remember while developing locally
* Support methods defined on non-pointer receivers
*/
/* |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | moduleMainSrc generates the source code of the main func for Dagger Module code using the Go SDK.
The overall idea is that users just need to create a struct with the same name as their Module and then
add methods to that struct to implement their Module. Methods on that struct become Functions.
They are also free to return custom objects from Functions, which themselves may have methods that become
Functions too. However, only the "top-level" Module struct's Functions will be directly invokable.
This is essentially just the GraphQL execution model.
The implementation works by parsing the user's code and generating a main func that reads function call inputs
from the Engine, calls the relevant function and returns the result. The generated code is mostly a giant switch/case
on the object+function name, with each case doing json deserialization of the input arguments and calling the actual
Go function.
*/
func (funcs goTemplateFuncs) moduleMainSrc() string {
if funcs.modulePkg == nil {
return `func main() { panic("no code yet") }`
}
ps := &parseState{
pkg: funcs.modulePkg,
fset: funcs.moduleFset,
methods: make(map[string][]method),
}
pkgScope := funcs.modulePkg.Types.Scope()
objFunctionCases := map[string][]Code{}
createMod := Qual("dag", "CurrentModule").Call()
objs := []types.Object{}
for _, name := range pkgScope.Names() {
obj := pkgScope.Lookup(name)
if obj == nil {
continue |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | }
objs = append(objs, obj)
}
sort.Slice(objs, func(i, j int) bool {
return objs[i].Pos() < objs[j].Pos()
})
tps := []types.Type{}
for _, obj := range objs {
tps = append(tps, obj.Type())
}
added := map[string]struct{}{}
topLevel := true
for len(tps) != 0 {
for _, tp := range tps {
named, isNamed := tp.(*types.Named)
if !isNamed {
continue
}
obj := named.Obj()
if obj.Pkg() != funcs.modulePkg.Types {
continue
}
strct, isStruct := named.Underlying().(*types.Struct)
if !isStruct {
continue
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | if _, ok := added[obj.Name()]; ok {
continue
}
objType, err := ps.goStructToAPIType(strct, named)
if err != nil {
panic(err)
}
if objType == nil {
continue
}
if err := ps.fillObjectFunctionCases(named, objFunctionCases); err != nil {
panic(err)
}
if len(objFunctionCases[obj.Name()]) == 0 {
if topLevel {
continue
}
if ps.isDaggerGenerated(named.Obj()) {
continue
}
}
createMod = dotLine(createMod, "WithObject").Call(Add(Line(), objType))
added[obj.Name()] = struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | }
tps, ps.extraTypes = ps.extraTypes, nil
topLevel = false
}
return strings.Join([]string{mainSrc, invokeSrc(objFunctionCases, createMod)}, "\n")
}
func dotLine(a *Statement, id string) *Statement {
return a.Op(".").Line().Id(id)
}
const (
mainSrc = `func main() { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | ctx := context.Background()
fnCall := dag.CurrentFunctionCall()
parentName, err := fnCall.ParentName(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
fnName, err := fnCall.Name(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
parentJson, err := fnCall.Parent(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
fnArgs, err := fnCall.InputArgs(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
inputArgs := map[string][]byte{}
for _, fnArg := range fnArgs {
argName, err := fnArg.Name(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
argValue, err := fnArg.Value(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
inputArgs[argName] = []byte(argValue)
}
result, err := invoke(ctx, []byte(parentJson), parentName, fnName, inputArgs)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
resultBytes, err := json.Marshal(result)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
_, err = fnCall.ReturnValue(ctx, JSON(resultBytes))
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
}
`
parentJSONVar = "parentJSON"
parentNameVar = "parentName"
fnNameVar = "fnName"
inputArgsVar = "inputArgs"
invokeFuncName = "invoke"
)
func invokeSrc(objFunctionCases map[string][]Code, createMod Code) string { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | objCases := []Code{}
for objName, functionCases := range objFunctionCases {
objCases = append(objCases, Case(Lit(objName)).Block(Switch(Id(fnNameVar)).Block(functionCases...)))
}
objCases = append(objCases, Case(Lit("")).Block(
Return(createMod, Nil()),
))
objCases = append(objCases, Default().Block(
Return(Nil(), Qual("fmt", "Errorf").Call(Lit("unknown object %s"), Id(parentNameVar))),
))
objSwitch := Switch(Id(parentNameVar)).Block(objCases...)
invokeFunc := Func().Id(invokeFuncName).Params(
Id("ctx").Qual("context", "Context"),
Id(parentJSONVar).Index().Byte(),
Id(parentNameVar).String(),
Id(fnNameVar).String(),
Id(inputArgsVar).Map(String()).Index().Byte(),
).Params( |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | Id("any"),
Error(),
).Block(objSwitch)
return fmt.Sprintf("%#v", invokeFunc)
}
func renderNameOrStruct(t types.Type) string {
if ptr, ok := t.(*types.Pointer); ok {
return "*" + renderNameOrStruct(ptr.Elem())
}
if sl, ok := t.(*types.Slice); ok {
return "[]" + renderNameOrStruct(sl.Elem())
}
if st, ok := t.(*types.Struct); ok {
result := "struct {\n"
for i := 0; i < st.NumFields(); i++ {
if !st.Field(i).Embedded() {
result += st.Field(i).Name() + " "
}
result += renderNameOrStruct(st.Field(i).Type())
if tag := st.Tag(i); tag != "" {
result += " `" + tag + "`"
}
result += "\n"
}
result += "}"
return result
}
if named, ok := t.(*types.Named); ok { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | base := named.Obj().Name()
if typeArgs := named.TypeArgs(); typeArgs.Len() > 0 {
base += "["
for i := 0; i < typeArgs.Len(); i++ {
if i > 0 {
base += ", "
}
base += renderNameOrStruct(typeArgs.At(i))
}
base += "]"
}
return base
}
return t.String()
}
var checkErrStatement = If(Err().Op("!=").Nil()).Block(
Qual("fmt", "Println").Call(Err().Dot("Error").Call()),
Qual("os", "Exit").Call(Lit(2)),
)
func (ps *parseState) fillObjectFunctionCases(type_ types.Type, cases map[string][]Code) error { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | var objName string
switch x := type_.(type) {
case *types.Pointer:
return ps.fillObjectFunctionCases(x.Elem(), cases)
case *types.Named:
objName = x.Obj().Name()
default:
return nil
}
if existingCases := cases[objName]; len(existingCases) > 0 {
return nil
}
methods := ps.methods[objName]
if len(methods) == 0 {
return nil
}
for _, method := range methods {
fnName, sig := method.fn.Name(), method.fn.Type().(*types.Signature)
statements := []Code{
Var().Id("err").Error(),
}
parentVarName := "parent"
statements = append(statements,
Var().Id(parentVarName).Id(objName),
Err().Op("=").Qual("json", "Unmarshal").Call(Id(parentJSONVar), Op("&").Id(parentVarName)),
checkErrStatement,
)
fnCallArgs := []Code{Op("&").Id(parentVarName)}
vars := map[string]struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | for i, spec := range method.paramSpecs {
if i == 0 && spec.paramType.String() == contextTypename {
fnCallArgs = append(fnCallArgs, Id("ctx"))
continue
}
var varName string
var varType types.Type
var target *Statement
if spec.parent == nil {
varName = strcase.ToLowerCamel(spec.name)
varType = spec.paramType
target = Id(varName)
} else {
varName = spec.parent.name
varType = spec.parent.paramType
target = Id(spec.parent.name).Dot(spec.name)
}
if _, ok := vars[varName]; !ok {
vars[varName] = struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | tp, access := findOptsAccessPattern(varType, Id(varName))
statements = append(statements, Var().Id(varName).Id(renderNameOrStruct(tp)))
if spec.variadic {
fnCallArgs = append(fnCallArgs, access.Op("..."))
} else {
fnCallArgs = append(fnCallArgs, access)
}
}
statements = append(statements,
If(Id(inputArgsVar).Index(Lit(spec.graphqlName())).Op("!=").Nil()).Block(
Err().Op("=").Qual("json", "Unmarshal").Call( |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | Index().Byte().Parens(Id(inputArgsVar).Index(Lit(spec.graphqlName()))),
Op("&").Add(target),
),
checkErrStatement,
))
}
results := sig.Results()
switch results.Len() {
case 2:
if results.At(1).Type().String() != errorTypeName {
return fmt.Errorf("second return value must be error, have %s", results.At(0).Type().String())
}
statements = append(statements, Return(
Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...),
))
cases[objName] = append(cases[objName], Case(Lit(fnName)).Block(statements...))
if err := ps.fillObjectFunctionCases(results.At(0).Type(), cases); err != nil {
return err
}
case 1:
if results.At(0).Type().String() == errorTypeName {
statements = append(statements, Return(
Nil(),
Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...),
))
cases[objName] = append(cases[objName], Case(Lit(fnName)).Block(statements...))
} else { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | statements = append(statements, Return(
Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...),
Nil(),
))
cases[objName] = append(cases[objName], Case(Lit(fnName)).Block(statements...))
if err := ps.fillObjectFunctionCases(results.At(0).Type(), cases); err != nil {
return err
}
}
case 0:
statements = append(statements,
Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...),
Return(Nil(), Nil()))
cases[objName] = append(cases[objName], Case(Lit(fnName)).Block(statements...))
default:
return fmt.Errorf("unexpected number of results from method %s: %d", fnName, results.Len())
}
}
cases[objName] = append(cases[objName], Default().Block(
Return(Nil(), Qual("fmt", "Errorf").Call(Lit("unknown function %s"), Id(fnNameVar))),
))
return nil
}
type parseState struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | pkg *packages.Package
fset *token.FileSet
methods map[string][]method
extraTypes []types.Type
}
type method struct {
fn *types.Func
paramSpecs []paramSpec
}
func (ps *parseState) goTypeToAPIType(typ types.Type, named *types.Named) (*Statement, error) {
ps.extraTypes = append(ps.extraTypes, typ)
switch t := typ.(type) {
case *types.Named:
typeDef, err := ps.goTypeToAPIType(t.Underlying(), t)
if err != nil {
return nil, fmt.Errorf("failed to convert named type: %w", err)
}
return typeDef, nil
case *types.Pointer:
return ps.goTypeToAPIType(t.Elem(), named)
case *types.Basic: |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | if t.Kind() == types.Invalid {
return nil, fmt.Errorf("invalid type: %+v", t)
}
var kind Code
switch t.Info() {
case types.IsString:
kind = Id("Stringkind")
case types.IsInteger:
kind = Id("Integerkind")
case types.IsBoolean:
kind = Id("Booleankind")
default:
return nil, fmt.Errorf("unsupported basic type: %+v", t)
}
return Qual("dag", "TypeDef").Call().Dot("WithKind").Call(
kind,
), nil
case *types.Slice:
elemTypeDef, err := ps.goTypeToAPIType(t.Elem(), nil)
if err != nil {
return nil, fmt.Errorf("failed to convert slice element type: %w", err)
}
return Qual("dag", "TypeDef").Call().Dot("WithListOf").Call(
elemTypeDef,
), nil
case *types.Struct:
if named == nil {
return nil, fmt.Errorf("struct types must be named")
}
typeName := named.Obj().Name() |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | if typeName == "" {
return nil, fmt.Errorf("struct types must be named")
}
return Qual("dag", "TypeDef").Call().Dot("WithObject").Call(
Lit(typeName),
), nil
default:
return nil, fmt.Errorf("unsupported type %T", t)
}
}
const errorTypeName = "error"
func (ps *parseState) goStructToAPIType(t *types.Struct, named *types.Named) (*Statement, error) {
if named == nil {
return nil, fmt.Errorf("struct types must be named")
}
typeName := named.Obj().Name()
if typeName == "" {
return nil, fmt.Errorf("struct types must be named")
}
objectIsDaggerGenerated := ps.isDaggerGenerated(named.Obj())
methods := []*types.Func{}
methodSet := types.NewMethodSet(types.NewPointer(named))
for i := 0; i < methodSet.Len(); i++ {
methodObj := methodSet.At(i).Obj()
if ps.isDaggerGenerated(methodObj) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | continue
}
if objectIsDaggerGenerated {
return nil, fmt.Errorf("cannot define methods on objects from outside this module")
}
method, ok := methodObj.(*types.Func)
if !ok {
return nil, fmt.Errorf("expected method to be a func, got %T", methodObj)
}
if !method.Exported() {
continue
}
methods = append(methods, method)
}
if objectIsDaggerGenerated {
return nil, nil
}
sort.Slice(methods, func(i, j int) bool {
return methods[i].Pos() < methods[j].Pos()
})
withObjectArgs := []Code{
Lit(typeName),
}
withObjectOpts := []Code{}
typeSpec, err := ps.typeSpecForNamedType(named)
if err != nil {
return nil, fmt.Errorf("failed to find decl for named type %s: %w", typeName, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | }
if doc := typeSpec.Doc; doc != nil {
withObjectOpts = append(withObjectOpts, Id("Description").Op(":").Lit(doc.Text()))
}
if len(withObjectOpts) > 0 {
withObjectArgs = append(withObjectArgs, Id("TypeDefWithObjectOpts").Values(withObjectOpts...))
}
typeDef := Qual("dag", "TypeDef").Call().Dot("WithObject").Call(withObjectArgs...)
for _, method := range methods {
fnTypeDef, err := ps.goMethodToAPIFunctionDef(typeName, method, named)
if err != nil {
return nil, fmt.Errorf("failed to convert method %s to function def: %w", method.Name(), err)
}
typeDef = dotLine(typeDef, "WithFunction").Call(Add(Line(), fnTypeDef))
}
astStructType, ok := typeSpec.Type.(*ast.StructType)
if !ok {
return nil, fmt.Errorf("expected type spec to be a struct, got %T", typeSpec.Type)
}
for i := 0; i < t.NumFields(); i++ {
field := t.Field(i)
if !field.Exported() {
continue
}
fieldTypeDef, err := ps.goTypeToAPIType(field.Type(), nil)
if err != nil {
return nil, fmt.Errorf("failed to convert field type: %w", err)
}
var description string |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | if doc := astStructType.Fields.List[i].Doc; doc != nil {
description = doc.Text()
}
withFieldArgs := []Code{
Lit(field.Name()),
fieldTypeDef,
}
if description != "" {
withFieldArgs = append(withFieldArgs,
Id("TypeDefWithFieldOpts").Values(
Id("Description").Op(":").Lit(description),
))
}
typeDef = dotLine(typeDef, "WithField").Call(withFieldArgs...)
}
return typeDef, nil
}
var voidDef = Qual("dag", "TypeDef").Call().
Dot("WithKind").Call(Id("Voidkind")).
Dot("WithOptional").Call(Lit(true))
func (ps *parseState) goMethodToAPIFunctionDef(typeName string, fn *types.Func, named *types.Named) (*Statement, error) {
methodSig, ok := fn.Type().(*types.Signature)
if !ok {
return nil, fmt.Errorf("expected method to be a func, got %T", fn.Type())
}
specs, err := ps.parseParamSpecs(fn)
if err != nil {
return nil, err |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | }
ps.methods[typeName] = append(ps.methods[typeName], method{fn: fn, paramSpecs: specs})
var fnReturnType *Statement
methodResults := methodSig.Results()
switch methodResults.Len() {
case 0:
fnReturnType = voidDef
case 1:
result := methodResults.At(0).Type()
if result.String() == errorTypeName {
fnReturnType = voidDef
} else {
fnReturnType, err = ps.goTypeToAPIType(result, nil)
if err != nil {
return nil, fmt.Errorf("failed to convert result type: %w", err)
}
}
case 2:
result := methodResults.At(0).Type()
fnReturnType, err = ps.goTypeToAPIType(result, nil)
if err != nil {
return nil, fmt.Errorf("failed to convert result type: %w", err)
}
default:
return nil, fmt.Errorf("method %s has too many return values", fn.Name())
}
fnDef := Qual("dag", "Function").Call(Lit(fn.Name()), Add(Line(), fnReturnType))
funcDecl, err := ps.declForFunc(fn)
if err != nil {
return nil, fmt.Errorf("failed to find decl for method %s: %w", fn.Name(), err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | }
if doc := funcDecl.Doc; doc != nil {
fnDef = dotLine(fnDef, "WithDescription").Call(Lit(doc.Text()))
}
for i, spec := range specs {
if i == 0 && spec.paramType.String() == contextTypename {
continue
}
typeDef, err := ps.goTypeToAPIType(spec.baseType, nil)
if err != nil {
return nil, fmt.Errorf("failed to convert param type: %w", err)
}
if spec.optional {
typeDef = typeDef.Dot("WithOptional").Call(Lit(true))
}
args := []Code{Lit(spec.graphqlName()), typeDef}
argOpts := []Code{}
if spec.description != "" {
argOpts = append(argOpts, Id("Description").Op(":").Lit(spec.description))
}
if spec.defaultValue != "" {
var jsonEnc string
if spec.baseType.String() == "string" {
enc, err := json.Marshal(spec.defaultValue)
if err != nil {
return nil, fmt.Errorf("failed to marshal default value: %w", err)
}
jsonEnc = string(enc) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | } else {
jsonEnc = spec.defaultValue
}
argOpts = append(argOpts, Id("DefaultValue").Op(":").Id("JSON").Call(Lit(jsonEnc)))
}
if len(argOpts) > 0 {
args = append(args, Id("FunctionWithArgOpts").Values(argOpts...))
}
fnDef = dotLine(fnDef, "WithArg").Call(args...)
}
return fnDef, nil
}
func (ps *parseState) parseParamSpecs(fn *types.Func) ([]paramSpec, error) {
sig := fn.Type().(*types.Signature)
params := sig.Params()
if params.Len() == 0 {
return nil, nil
}
specs := make([]paramSpec, 0, params.Len())
i := 0
if params.At(i).Type().String() == contextTypename {
spec, err := ps.parseParamSpecVar(params.At(i))
if err != nil {
return nil, err
}
specs = append(specs, spec)
i++
}
fnDecl, err := ps.declForFunc(fn)
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | return nil, err
}
if i+1 == params.Len() {
param := params.At(i)
paramType, ok := asInlineStruct(param.Type())
if ok {
stype, ok := asInlineStructAst(fnDecl.Type.Params.List[i].Type)
if !ok {
return nil, fmt.Errorf("expected struct type for %s", param.Name())
}
parent := ¶mSpec{
name: params.At(i).Name(),
paramType: param.Type(),
baseType: param.Type(),
}
for f := 0; f < paramType.NumFields(); f++ {
spec, err := ps.parseParamSpecVar(paramType.Field(f))
if err != nil {
return nil, err
}
spec.parent = parent
spec.description = stype.Fields.List[f].Doc.Text()
if spec.description == "" {
spec.description = stype.Fields.List[f].Comment.Text()
}
spec.description = strings.TrimSpace(spec.description)
specs = append(specs, spec)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | return specs, nil
}
}
for ; i < params.Len(); i++ {
spec, err := ps.parseParamSpecVar(params.At(i))
if err != nil {
return nil, err
}
if sig.Variadic() && i == params.Len()-1 {
spec.variadic = true
}
if cmt, err := ps.commentForFuncField(fnDecl, i); err == nil {
spec.description = cmt.Text()
spec.description = strings.TrimSpace(spec.description)
}
specs = append(specs, spec)
}
return specs, nil
}
func (ps *parseState) parseParamSpecVar(field *types.Var) (paramSpec, error) {
if _, ok := field.Type().(*types.Struct); ok {
return paramSpec{}, fmt.Errorf("nested structs are not supported")
}
paramType := field.Type()
baseType := paramType
for {
ptr, ok := baseType.(*types.Pointer)
if !ok { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | break
}
baseType = ptr.Elem()
}
optional := false
if named, ok := baseType.(*types.Named); ok {
if named.Obj().Name() == "Optional" && ps.isDaggerGenerated(named.Obj()) {
typeArgs := named.TypeArgs()
if typeArgs.Len() != 1 {
return paramSpec{}, fmt.Errorf("optional type must have exactly one type argument")
}
optional = true
baseType = typeArgs.At(0)
for {
ptr, ok := baseType.(*types.Pointer)
if !ok {
break
}
baseType = ptr.Elem()
}
}
}
return paramSpec{
name: field.Name(),
paramType: paramType,
baseType: baseType,
optional: optional,
}, nil
}
type paramSpec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | name string
description string
optional bool
variadic bool
defaultValue string
paramType types.Type
baseType types.Type
parent *paramSpec
}
func (spec *paramSpec) graphqlName() string {
return strcase.ToLowerCamel(spec.name)
}
func (ps *parseState) typeSpecForNamedType(namedType *types.Named) (*ast.TypeSpec, error) {
tokenFile := ps.fset.File(namedType.Obj().Pos())
if tokenFile == nil {
return nil, fmt.Errorf("no file for %s", namedType.Obj().Name())
}
for _, f := range ps.pkg.Syntax {
if ps.fset.File(f.Pos()) != tokenFile {
continue
}
for _, decl := range f.Decls {
genDecl, ok := decl.(*ast.GenDecl)
if !ok { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | continue
}
for _, spec := range genDecl.Specs {
typeSpec, ok := spec.(*ast.TypeSpec)
if !ok {
continue
}
if typeSpec.Name.Name == namedType.Obj().Name() {
return typeSpec, nil
}
}
}
}
return nil, fmt.Errorf("no decl for %s", namedType.Obj().Name())
}
func (ps *parseState) declForFunc(fnType *types.Func) (*ast.FuncDecl, error) {
tokenFile := ps.fset.File(fnType.Pos())
if tokenFile == nil {
return nil, fmt.Errorf("no file for %s", fnType.Name())
}
for _, f := range ps.pkg.Syntax {
if ps.fset.File(f.Pos()) != tokenFile {
continue
}
for _, decl := range f.Decls {
fnDecl, ok := decl.(*ast.FuncDecl)
if ok && fnDecl.Name.Name == fnType.Name() {
return fnDecl, nil
}
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | }
return nil, fmt.Errorf("no decl for %s", fnType.Name())
}
func (ps *parseState) commentForFuncField(fnDecl *ast.FuncDecl, i int) (*ast.CommentGroup, error) {
pos := fnDecl.Type.Params.List[i].Pos()
tokenFile := ps.fset.File(pos)
if tokenFile == nil {
return nil, fmt.Errorf("no file for function %s", fnDecl.Name.Name)
}
line := tokenFile.Line(pos)
allowDocComment := true
allowLineComment := true
if i == 0 && tokenFile.Line(fnDecl.Pos()) == line {
allowDocComment = false
} else if i > 0 && tokenFile.Line(fnDecl.Type.Params.List[i-1].Pos()) == line {
allowDocComment = false
}
if i+1 < len(fnDecl.Type.Params.List) && tokenFile.Line(fnDecl.Type.Params.List[i+1].Pos()) == line {
allowLineComment = false
}
for _, f := range ps.pkg.Syntax {
if ps.fset.File(f.Pos()) != tokenFile {
continue
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | if allowDocComment {
npos := tokenFile.LineStart(tokenFile.Line(pos)) - 1
for _, comment := range f.Comments {
if comment.Pos() <= npos && npos <= comment.End() {
return comment, nil
}
}
}
if allowLineComment {
npos := tokenFile.LineStart(tokenFile.Line(pos)+1) - 1
for _, comment := range f.Comments {
if comment.Pos() <= npos && npos <= comment.End() {
return comment, nil
}
}
}
}
return nil, fmt.Errorf("no comment for function %s", fnDecl.Name.Name)
}
func (ps *parseState) isDaggerGenerated(obj types.Object) bool {
tokenFile := ps.fset.File(obj.Pos())
return filepath.Base(tokenFile.Name()) == daggerGenFilename
}
func findOptsAccessPattern(t types.Type, access *Statement) (types.Type, *Statement) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | switch t := t.(type) {
case *types.Pointer:
t2, val := findOptsAccessPattern(t.Elem(), access)
return t2, Id("ptr").Call(val)
default:
return t, access
}
}
func asInlineStruct(t types.Type) (*types.Struct, bool) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | cmd/codegen/generator/go/templates/modules.go | switch t := t.(type) {
case *types.Pointer:
return asInlineStruct(t.Elem())
case *types.Struct:
return t, true
default:
return nil, false
}
}
func asInlineStructAst(t ast.Node) (*ast.StructType, bool) {
switch t := t.(type) {
case *ast.StarExpr:
return asInlineStructAst(t.X)
case *ast.StructType:
return t, true
default:
return nil, false
}
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | package core
import (
"context"
_ "embed"
"errors"
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
"time"
"dagger.io/dagger"
"github.com/iancoleman/strcase"
"github.com/moby/buildkit/identity"
"github.com/stretchr/testify/require"
"github.com/tidwall/gjson"
"golang.org/x/sync/errgroup"
)
/* TODO: add coverage for
* dagger mod use
* dagger mod sync
* that the codegen of the testdata envs are up to date (or incorporate that into a cli command)
* if a dependency changes, then checks should re-run
*/
func TestModuleGoInit(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Run("from scratch", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=bare", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out)
})
t.Run("kebab-cases Go module name, camel-cases Dagger module name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=My-Module", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{myModule{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | require.NoError(t, err)
require.JSONEq(t, `{"myModule":{"containerEcho":{"stdout":"hello\n"}}}`, out)
generated, err := modGen.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module my-module")
})
t.Run("creates go.mod beneath an existing go.mod if root points beneath it", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/go.mod", dagger.ContainerWithNewFileOpts{
Contents: "module example.com/test\n",
}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
WithWorkdir("/work/ci").
With(daggerExec("mod", "init", "--name=beneathGoMod", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{beneathGoMod{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"beneathGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("names Go module after Dagger module", func(t *testing.T) {
generated, err := modGen.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module beneath-go-mod") |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | })
})
t.Run("respects existing go.mod", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
With(daggerExec("mod", "init", "--name=hasGoMod", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{hasGoMod{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("preserves module name", func(t *testing.T) {
generated, err := modGen.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module example.com/test")
})
})
t.Run("respects parent go.mod if root points to it", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | Contents: "package foo\n",
}).
WithWorkdir("/work/child").
With(daggerExec("mod", "init", "--name=child", "--sdk=go", "--root=..")).
WithNewFile("/work/child/main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
import "os"
type Child struct{}
func (m *Child) Root() *Directory {
wd, err := os.Getwd()
if err != nil {
panic(err)
}
return dag.Host().Directory(wd+"/..")
}
`,
})
generated := modGen.
With(daggerExec("mod", "sync")).
Directory(".")
logGen(ctx, t, generated)
out, err := modGen.
With(daggerQuery(`{child{root{entries}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"child":{"root":{"entries":["child","foo.go","go.mod","go.sum"]}}}`, out)
childEntries, err := generated.Entries(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | require.NotContains(t, childEntries, "go.mod")
t.Run("preserves parent module name", func(t *testing.T) {
generated, err := modGen.File("/work/go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module example.com/test")
})
})
t.Run("respects existing go.mod even if root points to parent that has go.mod", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
WithWorkdir("/work/child").
WithExec([]string{"go", "mod", "init", "my-mod"}).
With(daggerExec("mod", "init", "--name=child", "--sdk=go", "--root=..")).
WithNewFile("/work/child/main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
import "os"
type Child struct{}
func (m *Child) Root() *Directory {
wd, err := os.Getwd()
if err != nil {
panic(err)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | return dag.Host().Directory(wd+"/..")
}
`,
})
generated := modGen.
With(daggerExec("mod", "sync")).
Directory(".")
logGen(ctx, t, generated)
out, err := modGen.
With(daggerQuery(`{child{root{entries}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"child":{"root":{"entries":["child","foo.go","go.mod"]}}}`, out)
childEntries, err := generated.Entries(ctx)
require.NoError(t, err)
require.Contains(t, childEntries, "go.mod")
require.Contains(t, childEntries, "go.sum")
})
t.Run("respects existing main.go", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
type HasMainGo struct {} |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | func (m *HasMainGo) Hello() string { return "Hello, world!" }
`,
}).
With(daggerExec("mod", "init", "--name=hasMainGo", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{hasMainGo{hello}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasMainGo":{"hello":"Hello, world!"}}`, out)
})
t.Run("respects existing main.go even if it uses types not generated yet", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
type HasDaggerTypes struct {}
func (m *HasDaggerTypes) Hello() *Container {
return dag.Container().
From("` + alpineImage + `").
WithExec([]string{"echo", "Hello, world!"})
}
`,
}).
With(daggerExec("mod", "init", "--name=hasDaggerTypes", "--sdk=go"))
logGen(ctx, t, modGen.Directory(".")) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | out, err := modGen.
With(daggerQuery(`{hasDaggerTypes{hello{stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasDaggerTypes":{"hello":{"stdout":"Hello, world!\n"}}}`, out)
})
t.Run("respects existing package without creating main.go", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/notmain.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type HasNotMainGo struct {}
func (m *HasNotMainGo) Hello() string { return "Hello, world!" }
`,
}).
With(daggerExec("mod", "init", "--name=hasNotMainGo", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{hasNotMainGo{hello}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasNotMainGo":{"hello":"Hello, world!"}}`, out)
})
}
func TestModuleGit(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | sdk string
gitignores []string
gitattributes string
}
for _, tc := range []testCase{
{
sdk: "go",
gitignores: []string{
"/dagger.gen.go\n",
"/querybuilder/\n",
},
},
{
sdk: "python",
gitignores: []string{
"/sdk\n",
},
},
} {
tc := tc |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Run(fmt.Sprintf("module %s git", tc.sdk), func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := goGitBase(t, c).
With(daggerExec("mod", "init", "--name=bare", "--sdk="+tc.sdk))
if tc.sdk == "go" {
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out)
} else {
out, err := modGen.
With(daggerQuery(`{bare{myFunction(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"myFunction":{"stdout":"hello\n"}}}`, out)
}
t.Run("configures .gitignore", func(t *testing.T) {
ignore, err := modGen.File(".gitignore").Contents(ctx)
require.NoError(t, err)
for _, gitignore := range tc.gitignores {
require.Contains(t, ignore, gitignore)
}
})
})
}
}
func TestModuleGoGitRemovesIgnored(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
committedModGen := goGitBase(t, c).
With(daggerExec("mod", "init", "--name=bare", "--sdk=go")).
WithExec([]string{"rm", ".gitignore"}).
WithExec([]string{"mkdir", "./internal"}).
WithExec([]string{"cp", "-a", "./querybuilder", "./internal/querybuilder"}).
WithExec([]string{"git", "add", "."}).
WithExec([]string{"git", "commit", "-m", "init with generated files"})
changedAfterSync, err := committedModGen.
With(daggerExec("mod", "sync")).
WithExec([]string{"git", "diff"}).
WithExec([]string{"git", "status", "--short"}).
Stdout(ctx)
require.NoError(t, err)
t.Logf("changed after sync:\n%s", changedAfterSync)
require.Contains(t, changedAfterSync, "D dagger.gen.go\n")
require.Contains(t, changedAfterSync, "D querybuilder/marshal.go\n")
require.Contains(t, changedAfterSync, "D querybuilder/querybuilder.go\n")
require.Contains(t, changedAfterSync, "D internal/querybuilder/marshal.go\n")
require.Contains(t, changedAfterSync, "D internal/querybuilder/querybuilder.go\n")
}
func TestModulePythonGitRemovesIgnored(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
committedModGen := goGitBase(t, c).
With(daggerExec("mod", "init", "--name=bare", "--sdk=python")).
WithExec([]string{"rm", ".gitignore"}).
WithExec([]string{"git", "add", "."}).
WithExec([]string{"git", "commit", "-m", "init with generated files"})
changedAfterSync, err := committedModGen.
With(daggerExec("mod", "sync")).
WithExec([]string{"git", "diff"}).
WithExec([]string{"git", "status", "--short"}).
Stdout(ctx)
require.NoError(t, err)
t.Logf("changed after sync:\n%s", changedAfterSync)
require.Contains(t, changedAfterSync, "D sdk/pyproject.toml\n")
require.Contains(t, changedAfterSync, "D sdk/src/dagger/__init__.py\n")
}
var goSignatures string
func TestModuleGoSignatures(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: goSignatures,
})
logGen(ctx, t, modGen.Directory("."))
t.Run("func Hello() string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"hello":"hello"}}`, out)
})
t.Run("func Echo(string) string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echo(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echo":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoPointer(*string) string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | require.JSONEq(t, `{"minimal":{"echoPointer":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoPointerPointer(**string) string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoPointerPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoPointerPointer":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoOptional(string) string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoOptional(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptional":"hello...hello...hello..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptional}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptional":"default...default...default..."}}`, out)
})
t.Run("func EchoOptionalPointer(string) string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoOptionalPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"hello...hello...hello..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptionalPointer}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"default...default...default..."}}`, out)
})
t.Run("func Echoes([]string) []string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoes(msgs: "hello")}}`)).Stdout(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | require.JSONEq(t, `{"minimal":{"echoes":["hello...hello...hello..."]}}`, out)
})
t.Run("func EchoesVariadic(...string) string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoesVariadic(msgs: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoesVariadic":"hello...hello...hello..."}}`, out)
})
t.Run("func HelloContext(context.Context) string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{helloContext}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloContext":"hello context"}}`, out)
})
t.Run("func EchoContext(context.Context, string) string", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoContext(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoContext":"ctx.hello...ctx.hello...ctx.hello..."}}`, out)
})
t.Run("func HelloStringError() (string, error)", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{helloStringError}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloStringError":"hello i worked"}}`, out)
})
t.Run("func HelloVoid()", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{helloVoid}}`)).Stdout(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | require.JSONEq(t, `{"minimal":{"helloVoid":null}}`, out)
})
t.Run("func HelloVoidError() error", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{helloVoidError}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloVoidError":null}}`, out)
})
t.Run("func EchoOpts(string, string, int) error", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOpts":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOpts":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInline(struct{string, string, int}) error", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlinePointer(*struct{string, string, int}) error", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlinePointer(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | require.JSONEq(t, `{"minimal":{"echoOptsInlinePointer":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlinePointer(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlinePointer":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlineCtx(ctx, struct{string, string, int}) error", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlineCtx(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineCtx":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlineCtx(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineCtx":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlineTags(struct{string, string, int}) error", func(t *testing.T) {
t.Parallel()
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlineTags(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineTags":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlineTags(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineTags":"hi!hi!"}}`, out)
})
}
var inspectModule = daggerQuery(`
query {
host {
directory(path: ".") {
asModule {
objects { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | asObject {
name
functions {
name
description
args {
name
description
}
}
}
}
}
}
}
}
`)
func TestModuleGoDocs(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: goSignatures,
})
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.With(inspectModule).Stdout(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | obj := gjson.Get(out, "host.directory.asModule.objects.0.asObject")
require.Equal(t, "Minimal", obj.Get("name").String())
hello := obj.Get(`functions.#(name="hello")`)
require.Equal(t, "hello", hello.Get("name").String())
require.Empty(t, hello.Get("description").String())
require.Empty(t, hello.Get("args").Array())
echoOpts := obj.Get(`functions.#(name="echoOpts")`)
require.Equal(t, "echoOpts", echoOpts.Get("name").String())
require.Equal(t, "EchoOpts does some opts things", echoOpts.Get("description").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String())
require.Equal(t, "the message to echo", echoOpts.Get("args.0.description").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
echoOpts = obj.Get(`functions.#(name="echoOptsInline")`)
require.Equal(t, "echoOptsInline", echoOpts.Get("name").String())
require.Equal(t, "EchoOptsInline does some opts things", echoOpts.Get("description").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String())
require.Equal(t, "the message to echo", echoOpts.Get("args.0.description").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
}
func TestModuleGoDocsEdgeCases(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
// some docs
func (m *Minimal) Hello(foo string, bar string,
// hello
baz string, qux string, x string, // lol
) string {
return foo + bar
}
func (m *Minimal) HelloAgain(
foo string, // docs for foo
bar string,
) string {
return foo + bar |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | }
`,
})
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.With(inspectModule).Stdout(ctx)
require.NoError(t, err)
obj := gjson.Get(out, "host.directory.asModule.objects.0.asObject")
require.Equal(t, "Minimal", obj.Get("name").String())
hello := obj.Get(`functions.#(name="hello")`)
require.Equal(t, "hello", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 5)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "", hello.Get("args.1.description").String())
require.Equal(t, "baz", hello.Get("args.2.name").String())
require.Equal(t, "hello", hello.Get("args.2.description").String())
require.Equal(t, "qux", hello.Get("args.3.name").String())
require.Equal(t, "", hello.Get("args.3.description").String())
require.Equal(t, "x", hello.Get("args.4.name").String())
require.Equal(t, "lol", hello.Get("args.4.description").String())
}
func TestModuleGoSignaturesMixMatch(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
func (m *Minimal) Hello(name string, opts struct{}, opts2 struct{}) string {
return name
}
`,
})
logGen(ctx, t, modGen.Directory("."))
_, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx)
require.Error(t, err)
}
func TestModuleGoSignaturesIDable(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Custom struct {
Data string
}
func (m *Minimal) Hello() string {
return "hello"
}
func (m *Minimal) UseCustom(custom *Custom) string {
return custom.Data
}
`,
})
logGen(ctx, t, modGen.Directory("."))
_, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx)
require.Error(t, err)
require.Contains(t, err.Error(), "Undefined type MinimalCustomID")
}
var goExtend string
func TestModuleGoExtendCore(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
_, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: goExtend,
}).
With(daggerExec("mod", "sync")).
Sync(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
require.Contains(t, logs.String(), "cannot define methods on objects from outside this module")
}
var customTypes string
func TestModuleGoCustomTypes(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=test", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: customTypes,
})
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.With(daggerQuery(`{test{repeater(msg:"echo!", times: 3){render}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"test":{"repeater":{"render":"echo!echo!echo!"}}}`, out)
}
func TestModuleGoReturnTypeDetection(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=foo", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Foo struct {}
type X struct {
Message string ` + "`json:\"message\"`" + `
}
func (m *Foo) MyFunction() X {
return X{Message: "foo"}
}
`,
})
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.With(daggerQuery(`{foo{myFunction{message}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"foo":{"myFunction":{"message":"foo"}}}`, out)
}
var useInner string
var useOuter string
func TestModuleGoUseLocal(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/dep").
With(daggerExec("mod", "init", "--name=dep", "--sdk=go")).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=use", "--sdk=go")).
WithNewFile("/work/dep/main.go", dagger.ContainerWithNewFileOpts{
Contents: useInner,
}).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: useOuter,
}).
With(daggerExec("mod", "use", "./dep")).
WithEnvVariable("BUST", identity.NewID())
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.With(daggerQuery(`{use{useHello}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"use":{"useHello":"hello"}}`, out)
_, err = modGen.With(daggerQuery(`{dep{hello}}`)).Stdout(ctx)
require.Error(t, err)
require.ErrorContains(t, err, `Cannot query field "dep" on type "Query".`)
}
func TestModuleGoUseLocalMulti(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/foo").
WithNewFile("/work/foo/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Foo struct {}
func (m *Foo) Name() string { return "foo" }
`,
}).
With(daggerExec("mod", "init", "--name=foo", "--sdk=go")).
WithWorkdir("/work/bar").
WithNewFile("/work/bar/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Bar struct {}
func (m *Bar) Name() string { return "bar" }
`,
}).
With(daggerExec("mod", "init", "--name=bar", "--sdk=go")). |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=use", "--sdk=go")).
With(daggerExec("mod", "use", "./foo")).
With(daggerExec("mod", "use", "./bar")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
import "fmt"
type Use struct {}
func (m *Use) Names(ctx context.Context) ([]string, error) {
fooName, err := dag.Foo().Name(ctx)
if err != nil {
return nil, fmt.Errorf("foo.name: %w", err)
}
barName, err := dag.Bar().Name(ctx)
if err != nil {
return nil, fmt.Errorf("bar.name: %w", err)
}
return []string{fooName, barName}, nil
}
`,
}).
WithEnvVariable("BUST", identity.NewID())
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.With(daggerQuery(`{use{names}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"use":{"names":["foo", "bar"]}}`, out)
}
var wrapper string
func TestModuleGoWrapping(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=wrapper", "--sdk=go")).
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: wrapper,
})
logGen(ctx, t, modGen.Directory("."))
id := identity.NewID()
out, err := modGen.With(daggerQuery(
fmt.Sprintf(`{wrapper{container{echo(msg:%q){unwrap{stdout}}}}}`, id),
)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t,
fmt.Sprintf(`{"wrapper":{"container":{"echo":{"unwrap":{"stdout":%q}}}}}`, id),
out)
}
func TestModuleConfigAPI(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
moduleDir := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work/subdir").
With(daggerExec("mod", "init", "--name=test", "--sdk=go", "--root=..")).
Directory("/work")
cfg := c.ModuleConfig(moduleDir, dagger.ModuleConfigOpts{Subpath: "subdir"})
name, err := cfg.Name(ctx)
require.NoError(t, err)
require.Equal(t, "test", name)
sdk, err := cfg.SDK(ctx)
require.NoError(t, err)
require.Equal(t, "go", sdk)
root, err := cfg.Root(ctx)
require.NoError(t, err)
require.Equal(t, "..", root)
}
func TestModulePythonInit(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | t.Run("from scratch", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("mod", "init", "--name=bare", "--sdk=python"))
out, err := modGen.
With(daggerQuery(`{bare{myFunction(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"myFunction":{"stdout":"hello\n"}}}`, out)
})
t.Run("respects existing pyproject.toml", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work"). |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | WithNewFile("pyproject.toml", dagger.ContainerWithNewFileOpts{
Contents: `[project]
name = "has-pyproject"
version = "0.0.0"
`,
}).
With(daggerExec("mod", "init", "--name=hasPyproject", "--sdk=python"))
out, err := modGen.
With(daggerQuery(`{hasPyproject{myFunction(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasPyproject":{"myFunction":{"stdout":"hello\n"}}}`, out)
t.Run("preserves module name", func(t *testing.T) {
generated, err := modGen.File("pyproject.toml").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, `name = "has-pyproject"`)
})
})
t.Run("respects existing main.py", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/src/main/__init__.py", dagger.ContainerWithNewFileOpts{
Contents: "from . import notmain\n",
}).
WithNewFile("/work/src/main/notmain.py", dagger.ContainerWithNewFileOpts{
Contents: `from dagger.mod import function
@function |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | def hello() -> str:
return "Hello, world!"
`,
}).
With(daggerExec("mod", "init", "--name=hasMainPy", "--sdk=python"))
out, err := modGen.
With(daggerQuery(`{hasMainPy{hello}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasMainPy":{"hello":"Hello, world!"}}`, out)
})
}
func TestModuleLotsOfFunctions(t *testing.T) {
t.Parallel()
const funcCount = 100
t.Run("go sdk", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
mainSrc := `
package main
type PotatoSack struct {}
`
for i := 0; i < funcCount; i++ {
mainSrc += fmt.Sprintf(`
func (m *PotatoSack) Potato%d() string {
return "potato #%d"
}
`, i, i)
}
modGen := c.Container().From(golangImage). |
closed | dagger/dagger | https://github.com/dagger/dagger | 5,971 | π `runtime error: index out of range` error when generating `go` modules | ### What is the issue?
Using common parameter types like following code block causing `runtime error: index out of range` while generating module code.
```go
func (ar *ActionRun) WithInput(name, value string) *ActionRun {
ar.Config.With = append(ar.Config.With, fmt.Sprintf("%s=%s", name, value))
return ar
}
```
### Log output
```shell
dagger mod sync
β asModule(sourceSubpath: "daggerverse/actions/runtime") ERROR [3.18s]
β exec /usr/local/bin/codegen --module . --propagate-logs=true ERROR [0.39s]
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β Usage:
β codegen [flags]
β
β Flags:
β -h, --help help for codegen
β --lang string language to generate (default "go")
β --module string module to load and codegen dependency code
β -o, --output string output directory (default ".")
β --propagate-logs propagate logs directly to progrock.sock
β
β Error: generate code: template: module:56:3: executing "module" at <Modu
β MainSrc>: error calling ModuleMainSrc: runtime error: index out of range
β 1] with length 1
β generating go module: actions-runtime ERROR [0.28s]
β’ Engine: d8c37de1d5af (version devel ())
β§ 4.89s β 238 β
2 β 3
Error: failed to automate vcs: failed to get vcs ignored paths: input:1: host.directory.asModule failed to call module "actions-runtime" to get functions: failed to get function output directory: process "/usr/local/bin/codegen --module . --propagate-logs=true" did not complete successfully: exit code: 1
```
### Steps to reproduce
- Create a go module
- Add command to module using shared type parameter like `func (ar *ActionRun) WithInput(name, value string) *ActionRun`
- Run `dagger mod sync`
### SDK version
Go SDK v0.9.1, Dagger CLI v0.9.1
### OS version
macOS 14.0 | https://github.com/dagger/dagger/issues/5971 | https://github.com/dagger/dagger/pull/5972 | c8990707600e665638707f19c12d4ecb80ef3e3a | 35442c542873fd260cddbcbed2ece93ce4b5a79f | 2023-10-26T15:48:07Z | go | 2023-10-26T17:53:44Z | core/integration/module_test.go | WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: mainSrc,
}).
With(daggerExec("mod", "init", "--name=potatoSack", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
var eg errgroup.Group
for i := 0; i < funcCount; i++ {
i := i
if i%10 != 0 {
continue
}
eg.Go(func() error {
_, err := modGen.
With(daggerCall(fmt.Sprintf("potato%d", i))).
Sync(ctx)
return err
})
}
require.NoError(t, eg.Wait())
})
t.Run("python sdk", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
mainSrc := `from dagger.mod import function
`
for i := 0; i < funcCount; i++ {
mainSrc += fmt.Sprintf(` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.