#Where are the golang docs for modules?

1 messages · Page 1 of 1 (latest)

cosmic meadow
#

I've been looking at the docs at the page linked to from the dagger.io docs. Lots of functions are not actually available to me when I try them with modules. (https://pkg.go.dev/dagger.io/dagger#section-readme)

From the general context I gather there was some paradigm shift recently and the new thing is modules.

The new user experience of that is a bit rough.

Where can I go to see what I actually have available in the preinitiated dag object in modules?

mighty ember
#

Thanks for sharing your experience, its always great to see where there is friction from a fresh set of eyes.

Everything besides Client should work as expected, can you let me know where you are running into an issue, something feels off.

uncut prairie
cosmic meadow
#

The first thing was client.Host

#

ah ok I see

#

Thanks Solomon!

#

let me put my thoughts together and give you a cohesive "this feels off"

#

and let me read that post as well before I ask something that's already been answered

mighty ember
#

dag.Host is not available inside a Dagger Function.

I think even adding some note to the SDK docs about this would feel like an improvement to me.

I am looking forward to hearing your other thoughts as well!

cosmic meadow
#

Ok so I guess my question is around this Host thing. I'm trying to mount a directory that's in the parent dir of where I'm running dagger.

project := dag.Directory().Directory("../project").

But the error I get is input: directory.directory resolve: /project: no such file or directory.

#

am I on the right track guessing that mounting things from outside the current directory is not allowed?

#

I tried using WithDirectory but that one in turn requires a Directory

mighty ember
#

The recommended approach, especially for the entrypoint into your pipeline, is to pass a directory into a function, rather than having a function read a directory.

You can see an example here: https://docs.dagger.io/manuals/developer/go/264203/functions#arguments

Dagger Functions are regular code, written in a supported programming language, and running in containers. Dagger Functions let you encapsulate common operations or workflows into discrete units with clear inputs and outputs.

#

But also, *Directory does not support relative paths so things can get a bit tricky here.

cosmic meadow
#

ah ok let me take a look

#

also I may have just found a bug

mighty ember
#

I would suggest putting dagger.json at the root of your repo so that you can easily reference everything underneath in the tree.

You can still put your dagger code in some other dir and point to that.

cosmic meadow
#

I pointed dag.Git("<absolute path to local git repo>.git") and dagger is simply hanging on connect 3m30s

#

ah!

#

ok

#

I'll try that, it sounds exactly like what I need

mighty ember
#

Ill be free in an hour if you wanna pair for a bit

#

Might be easier to get a kick start that way 😄

cosmic meadow
#

oh yeah sure

#

thanks! I think that would really help

mighty ember
#

awesome, ill come grab you in a bit

mighty ember
#

@cosmic meadow I am ready now if you are - ill DM you a zoom link

cosmic meadow
#

hey! ok

#

ready

#

hmm, I'm also learning how to use discord

rich cedar
cosmic meadow
#

thanks for that answer