Yaml 什么是`<<;`和`&;`我的意思是?
当我查看Yaml 什么是`<<;`和`&;`我的意思是?,yaml,hyperledger-fabric,Yaml,Hyperledger Fabric,当我查看cryptogen(结构命令)配置文件时。我看到了那个符号 Profiles: SampleInsecureSolo: Orderer: <<: *OrdererDefaults ## what is the `<<` Organizations: - *ExampleCom ## what is the `*` Consortium
cryptogen
(结构命令)配置文件时。我看到了那个符号
Profiles:
SampleInsecureSolo:
Orderer:
<<: *OrdererDefaults ## what is the `<<`
Organizations:
- *ExampleCom ## what is the `*`
Consortiums:
SampleConsortium:
Organizations:
- *Org1ExampleCom
- *Org2ExampleCom
如您所见,还有另一个符号&
。
我不知道这是什么意思。即使通过查看源代码(
fabric/common/configtx/tool/configtxgen/main.go
),我也没有得到任何信息。好的,这些是YAML文件格式的元素,在这里用于为configtxgen
提供配置文件。“&”符号表示锚点,“*”表示锚点,基本上用于避免重复,例如:
person: &person
name: "John Doe"
employee: &employee
<< : *person
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
使用了shelf YAML解析器,因此在configtxgen
相关代码中找不到对这些符号的任何引用。我建议您多读一点。尝试了您的“:@Wappenull:我可以确认您的修复,并相应地更新了答案。
key1: &key some very common value
key2: *key
key1: some very common value
key2: some very common value