-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a Commented CUE guide that demonstrates using path.Join to construct well-formed paths. One example of parent directory traversal is included. Preview-Path: /docs/howto/use-the-builtin-function-path-join-to-construct-well-formed-paths/ Signed-off-by: Jonathan Matthews <[email protected]> Change-Id: I046a00af48dd5a34e15affe49a7ab8949bd0d787 Dispatch-Trailer: {"type":"trybot","CL":1174728,"patchset":1,"ref":"refs/changes/28/1174728/1","targetBranch":"alpha"}
- Loading branch information
1 parent
39efc8c
commit b378567
Showing
4 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...s/howto/use-the-builtin-function-path-join-to-construct-well-formed-paths/en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
title: Using the builtin 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 builtin function `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) builtin package |
18 changes: 18 additions & 0 deletions
18
...ocs/howto/use-the-builtin-function-path-join-to-construct-well-formed-paths/gen_cache.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package site | ||
{ | ||
content: { | ||
docs: { | ||
howto: { | ||
"use-the-builtin-function-path-join-to-construct-well-formed-paths": { | ||
page: { | ||
cache: { | ||
code: { | ||
cc: "cse+WWX+uowJG/2noGjtURmZGxLi3Y7w3JjRT1BAHD0=" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ent/docs/howto/use-the-builtin-function-path-join-to-construct-well-formed-paths/page.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package site | ||
|
||
content: docs: howto: "use-the-builtin-function-path-join-to-construct-well-formed-paths": {} |
45 changes: 45 additions & 0 deletions
45
...owto/use-the-builtin-function-path-join-to-construct-well-formed-paths/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: Using the builtin 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 builtin function `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) builtin package |