Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go tutorial and reference #723

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

javierdelapuente
Copy link
Contributor

@javierdelapuente javierdelapuente commented Oct 2, 2024

  • Have you signed the CLA?

Adds a tutorial and reference docs for the Go extension

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 2, 2024
@javierdelapuente javierdelapuente marked this pull request as ready for review October 3, 2024 14:34

.. note::

``rockcraft pack`` will create a new image with the updated code even if you
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Should this pack command have ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS included in it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about that, the command to run is just below this line (with the correct env var set). I think this is referring to the generic "rockcraft pack". What do you think?

Copy link
Contributor

@jdkandersson jdkandersson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked at the tutorial, I think it is a good start

docs/tutorial/code/go/main.go Outdated Show resolved Hide resolved
docs/tutorial/go.rst Outdated Show resolved Hide resolved
docs/tutorial/go.rst Outdated Show resolved Hide resolved
docs/tutorial/go.rst Outdated Show resolved Hide resolved
:dedent: 2


Add another binary to the Go application
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of the other tutorials demonstrate how to update the application? I think this is fine to include perhaps as another step since we don't have the chisel anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replied in the next comment.

Comment on lines 257 to 258
Add the following snippet to the file ``rockcraft.yaml``, so the new binary is
set as the main application to run:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't follow why we would suggest the user does this?

Copy link
Contributor Author

@javierdelapuente javierdelapuente Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this because I think it is one of the pain points of the extension. Many Go projects have the binaries under cmd/, sometimes being one the server and the other ones could be for example command line tools.

I put this example to show how to use another binary, and at the same time how to "update" the application, put another version of the rock... Would you suggest another different example to update the app?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps that can be a separate how to. I would suggest just showing perhaps adding another endpoint like the time endpoint on other tutorials

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the tutorial doesn’t flow, it doesn’t make sense at least to me that I would want to add another binary at this point, I probably would just want to add some features

Copy link
Contributor Author

@javierdelapuente javierdelapuente Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, let me try that way (adding another endpoint) and I will leave that part for a how-to (I think it is important).

I will copy the flask endpoint in Go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

docs/tutorial/index.rst Outdated Show resolved Hide resolved
docs/tutorial/go.rst Outdated Show resolved Hide resolved
for you.

By default, the ``go-framework`` will use the ``bare`` base. You can improve
the developer experience changing the base to ``[email protected]``, but the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we caveat what we mean by this? E.g., for debugging it might be better to use but for production we recommend bare?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have rephrased it a bit. I think it is a bit clearer now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps rename this to main-time.go so that the editors recognise it as a go file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not use the .go extension because otherwise it will be compiled (and will fail).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants