yaml中的`<<`和`&`是什么意思?

时间:2017-10-09 07:48:04

标签: yaml hyperledger-fabric

当我查看_yourValue; @Input() set yourValue(val) { this._yourValue = val; } get yourValue() { return this._yourValue; } a fabric命令)配置文件时。我看到了符号。

cryptogen

上面有两个符号Profiles: SampleInsecureSolo: Orderer: <<: *OrdererDefaults ## what is the `<<` Organizations: - *ExampleCom ## what is the `*` Consortiums: SampleConsortium: Organizations: - *Org1ExampleCom - *Org2ExampleCom <<

*

如您所见,还有另一个符号Application: &ApplicationDefaults # what is the `&` mean Organizations: 。 我不知道有什么意思。即使查看源代码,我也没有收到任何信息( &

1 个答案:

答案 0 :(得分:8)

嗯,这些是YAML文件格式的元素,这里使用它来为configtxgen提供配置文件。 “&amp;” sign表示锚和“*”引用锚,这基本上用于避免重复,例如:

person: &person
    name: "John Doe"

employee: &employee
           : << *person
    salary : 5000

将重用人的字段并具有类似的含义:

employee: &employee
    name   : "John Doe"
    salary : 5000

另一个例子就是重复使用值:

key1: &key some very common value

key2: *key

相当于:

key1: some very common value

key2: some very common value

由于abric/common/configtx/tool/configtxgen/main.go使用了架子YAML解析器,因此在configtxgen相关代码中找不到对这些符号的任何引用。我建议您多阅读YAML file format

相关问题