libcontainer: move example code out of README#5127
Conversation
|
|
||
| ## Using libcontainer | ||
|
|
||
| For a brief overview of using libcontainer, see [example\_test.go](example_test.go). |
There was a problem hiding this comment.
nit
| For a brief overview of using libcontainer, see [example\_test.go](example_test.go). | |
| For a brief overview of using libcontainer, see [`example_test.go`](example_test.go). |
There was a problem hiding this comment.
This \ was deliberate, it escapes _ to ensure it's literal _ and not a special markdown character. In this case, it should work with or without escaping.
Yet, it's an issue with vim/nvim syntax/markdown.vim file which sometimes marks a lone unescaped _ as an error. It is not an error when inside [], but fixing it is beyond my abilities.
Removed.
| _ "github.com/opencontainers/runc/libcontainer/nsenter" | ||
| ) | ||
|
|
||
| func ExampleContainer() { |
There was a problem hiding this comment.
Does godoc produce the output you'd like for this?
IIRC ExampleXyz functions normally get associated with the exported symbol Xyz -- so I think this will get associated with libcontainer.Container.
If you wanted to make it package-level, I think you need to call it Example_container or something similar (that's what encoding/json does, at least...).
There was a problem hiding this comment.
Thanks! Indeed, ExampleContainer will be associated with the Container type, which is not what I want here.
Changed to Example_container. The local rendering (with godoc) differs from what we see on pkg.go.dev, and I still don't like what I see (e.g. no imports), but it's definitely an improvement over having the code in md file.
cyphar
left a comment
There was a problem hiding this comment.
Aside from the nit about godoc, LGTM.
Example code in README is outdated (especially since cgroups is moved to a separate repository) and lacks proper import statements. And, since it is not code, it is hard to keep it up to date. Let's move it out to the example_test.go file and refer to it. Note we still don't run it, but it will be compiled and linted in CI. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Example code in README is outdated (especially since cgroups is moved to a separate repository in #4638) and lacks proper import statements. And, since it is not code, it is hard to keep it up to date.
Let's move it out to the example_test.go file and refer to it. Note we still don't run it, but it will be compiled and linted in CI.
Closes: #4786
Fixes: #3863