diff --git a/content/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/en.md b/content/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/en.md new file mode 100644 index 000000000..bf43c7848 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/en.md @@ -0,0 +1,45 @@ +--- +title: Using the built-in function "path.Join" to construct well-formed paths +tags: +- commented cue +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in function +[`path.Join`](https://pkg.go.dev/cuelang.org/go/pkg/path#Join) +to construct well-formed paths from their individual string components. + +{{{with code "en" "cc"}}} +exec cue export +cmp stdout out +-- file.cue -- +package example + +import "path" + +inline: path.Join(["foo", "bar", "baz"], path.Unix) + +unix: path.Join(_components, path.Unix) +windows: path.Join(_components, path.Windows) + +_components: [ + "foo", + "bar", + "baz", + "..", + "quux", +] +-- out -- +{ + "inline": "foo/bar/baz", + "unix": "foo/bar/quux", + "windows": "foo\\bar\\quux" +} +{{{end}}} + +## Related content + +- The [`path`](https://pkg.go.dev/cuelang.org/go/pkg/path) built-in package diff --git a/content/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/gen_cache.cue b/content/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/gen_cache.cue new file mode 100644 index 000000000..d535cadfd --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/gen_cache.cue @@ -0,0 +1,18 @@ +package site +{ + content: { + docs: { + howto: { + "use-the-built-in-function-path-join-to-construct-well-formed-paths": { + page: { + cache: { + code: { + cc: "cse+WWX+uowJG/2noGjtURmZGxLi3Y7w3JjRT1BAHD0=" + } + } + } + } + } + } + } +} diff --git a/content/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/page.cue b/content/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/page.cue new file mode 100644 index 000000000..929b3cb10 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/page.cue @@ -0,0 +1,3 @@ +package site + +content: docs: howto: "use-the-built-in-function-path-join-to-construct-well-formed-paths": {} diff --git a/hugo/content/en/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/index.md b/hugo/content/en/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/index.md new file mode 100644 index 000000000..81d248e06 --- /dev/null +++ b/hugo/content/en/docs/howto/use-the-built-in-function-path-join-to-construct-well-formed-paths/index.md @@ -0,0 +1,46 @@ +--- +title: Using the built-in function "path.Join" to construct well-formed paths +tags: +- commented cue +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in function +[`path.Join`](https://pkg.go.dev/cuelang.org/go/pkg/path#Join) +to construct well-formed paths from their individual string components. + +{{< code-tabs >}} +{{< code-tab name="file.cue" language="cue" area="top-left" >}} +package example + +import "path" + +inline: path.Join(["foo", "bar", "baz"], path.Unix) + +unix: path.Join(_components, path.Unix) +windows: path.Join(_components, path.Windows) + +_components: [ + "foo", + "bar", + "baz", + "..", + "quux", +] +{{< /code-tab >}} +{{< code-tab name="TERMINAL" language="" type="terminal" area="top-right" >}} +$ cue export +{ + "inline": "foo/bar/baz", + "unix": "foo/bar/quux", + "windows": "foo\\bar\\quux" +} +{{< /code-tab >}} +{{< /code-tabs >}} + +## Related content + +- The [`path`](https://pkg.go.dev/cuelang.org/go/pkg/path) built-in package