You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just wondered if it is possible to create a package inside of the cells of a notebook. Would that be difficulty to implement?
How about something like %package something in the head of the cell to indicate that the code goes into a package. GONB then would create a directory named something and adds the code of all cells with that same package name into a file and prepends it with the package something header.
This package could then getting imported as all the others and help to write code that can easier be copied 1:1 into external projects.
The text was updated successfully, but these errors were encountered:
So, this is interesting and naturally would be cool to add.
But I would put this on the back of the list for now, because I believe it would be lots of work. Things it would require from the top of my head:
Supporting multiple memories of the current Go definitions (one per defined package)
Special handling for go get, go import and some hacks to make it work, that I'm not sure would work the same when building a package as opposed to main. Not sure.
Extend the %ls, %rm and %reset special commands to handle packages.
(As always, if you want to take a stab at it be my guest).
As an alternative -- probably not what you want, but ... -- during the GoMLX project development, I worked the whole time with gonb opened, using go work use <local gomlx path>, so I could keep editing in GoLand and playing around in GoNB, without having to do anything. Even the auto-complete in GoNB would pick up changes I made in GoLand immediately.
I am using go.work files similarly. But that is indeed not what I thought of.
When I see it correctly, a "package something" line in a cell is ignored. And even if not.
Could you add a feature that will ignore that package name in the go source? I mean if I write package something in a cell and then later use something.Func() that you remove the something. from the code for compilation and auto-completion?
This way one could write code "as if" it were in that package until one creates that package for real. When you created it for real, you do not need to rewrite all the code again and just need to remove the cells with those package names.
I could also try to take the original notebook and extract all the code for the packages, auto-create it and optionally update the code in the notebook.
Hello @janpfeifer,
I just wondered if it is possible to create a package inside of the cells of a notebook. Would that be difficulty to implement?
How about something like
%package something
in the head of the cell to indicate that the code goes into a package. GONB then would create a directory namedsomething
and adds the code of all cells with that same package name into a file and prepends it with thepackage something
header.This package could then getting imported as all the others and help to write code that can easier be copied 1:1 into external projects.
The text was updated successfully, but these errors were encountered: