在config.yml中替换dlv的路径示例。

huangapple go评论72阅读模式
英文:

dlv substitute-path example in config.yml

问题

在$HOME/.dlv/config.yml中设置from和to路径的示例是什么?我尝试了以下设置:

情况1(在from和to中使用引号)
substitute-path:

{"from":
"/private/var/tmp/_bazel/d3eb9a0ef06857aebc54b41ff425d2ee"
"to": "/Users/xxx/code/src"}

情况2(在from和to中不使用引号)
substitute-path:

{from:
"/private/var/tmp/_bazel/d3eb9a0ef06857aebc54b41ff425d2ee"
to: "/Users/xxx/code/src"}

情况3(在'from'之前使用连字符)
substitute-path:

-{from:
"/private/var/tmp/_bazel/d3eb9a0ef06857aebc54b41ff425d2ee"
to: "/Users/xxx/code/src"}

情况4(在'from'之前使用连字符)
substitute-path:

-{"from":
"/private/var/tmp/_bazel/d3eb9a0ef06857aebc54b41ff425d2ee"
"to": "/Users/xxx/code/src"}

这4种情况都会导致配置错误。有没有设置路径的有效示例?

英文:

Any example to set from and to path in $HOME/.dlv/config.yml ? I have tried setting:

case 1 ( with quotes in from and to)
substitute-path:

{"from":
"/private/var/tmp/_bazel/d3eb9a0ef06857aebc54b41ff425d2ee"
"to": "/Users/xxx/code/src"}

case 2: ( without quotes in from and to)
substitute-path:

{from:
"/private/var/tmp/_bazel/d3eb9a0ef06857aebc54b41ff425d2ee"
to: "/Users/xxx/code/src"}

case 2: ( with hyphan before '{from' )
substitute-path:

-{from:
"/private/var/tmp/_bazel/d3eb9a0ef06857aebc54b41ff425d2ee"
to: "/Users/xxx/code/src"}

case 2: ( with hyphan before '{from' )
substitute-path:

-{"from":
"/private/var/tmp/_bazel/d3eb9a0ef06857aebc54b41ff425d2ee"
"to": "/Users/xxx/code/src"}

all 4 cases fails with config. error.
any working sample to set the path?

答案1

得分: 0

我认为你漏掉了一个空格。引号只在值或键中包含空格或其他不可打印的非ASCII字符时才相关。

这是没有注释的配置:

$ cat ~/.config/dlv/config.yml | sed '/^#/d; /^$/d'
aliases:
  # command: ["alias1", "alias2"]
substitute-path:
  - {from: /my/source/code/was/here, to: /but/now/its/here}
debug-info-directories: ["/usr/lib/debug/.build-id"]

看起来是有效的YAML:

$ yq < ~/.config/dlv/config.yml
{
  "aliases": null,
  "substitute-path": [
    {
      "from": "/my/source/code/was/here",
      "to": "/but/now/its/here"
    }
  ],
  "debug-info-directories": [
    "/usr/lib/debug/.build-id"
  ]
}

yq工具是jq的包装器:

$ yq --help | sed 8q
usage: yq [options] <jq filter> [input file...]
          [jq_filter] [files [files ...]]

yq: Command-line YAML processor - jq wrapper for YAML documents

yq transcodes YAML documents to JSON and passes them to jq.
See https://github.com/kislyuk/yq for more information.
英文:

I think you are missing a space. The quotes are relevant only if the values or keys have spaces in them, or some other non-printable, non-ascii characters.

The config here, without comments:

$ cat ~/.config/dlv/config.yml | sed &#39;/^#/d; /^$/d&#39;
aliases:
  # command: [&quot;alias1&quot;, &quot;alias2&quot;]
substitute-path:
  - {from: /my/source/code/was/here, to: /but/now/its/here}
debug-info-directories: [&quot;/usr/lib/debug/.build-id&quot;]

Seems like valid yaml:

$ yq &lt; ~/.config/dlv/config.yml 
{
  &quot;aliases&quot;: null,
  &quot;substitute-path&quot;: [
    {
      &quot;from&quot;: &quot;/my/source/code/was/here&quot;,
      &quot;to&quot;: &quot;/but/now/its/here&quot;
    }
  ],
  &quot;debug-info-directories&quot;: [
    &quot;/usr/lib/debug/.build-id&quot;
  ]
}

The yq tool is a wrapper for jq.

$ yq --help | sed 8q
usage: yq [options] &lt;jq filter&gt; [input file...]
          [jq_filter] [files [files ...]]

yq: Command-line YAML processor - jq wrapper for YAML documents

yq transcodes YAML documents to JSON and passes them to jq.
See https://github.com/kislyuk/yq for more information.

huangapple
  • 本文由 发表于 2022年4月19日 12:19:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/71919621.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定