Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing README #2

Closed
lestrrat opened this issue Oct 23, 2019 · 1 comment · Fixed by #3
Closed

fixing README #2

lestrrat opened this issue Oct 23, 2019 · 1 comment · Fixed by #3

Comments

@lestrrat
Copy link
Contributor

READMEの英語を直したいのですが、いくつかわからないところがあるので教えてください

If omitted anchor name, assigned default rendering name ( strings.ToLower(FieldName) ) as anchor name. If omitted alias name and it's field type is pointer type, assigned anchor name automatically from same pointer address.

よくわからなかったので日本語でどういうことなのか教えてくれるとうれしいです!

@goccy
Copy link
Owner

goccy commented Oct 23, 2019

ありがとうございます!

タグの key として anchoralias をサポートしているのですが、

type A struct {
  B *B `yaml:"anchor=a"`
  C *C `yaml:"alias=a"`
}

のように anchoralias の value として名前を指定すると、その名前でエンコードしてくれるという経路 ( 以下のような出力結果になります )

b: &a
 ....
c: *a

と、 anchoralias に対応する名前を省略すると自動で反映してくれる経路

type A struct {
  B *B `yaml:"anchor"`
  C *B `yaml:"alias"`
}

( この状態で、 A.C に対して、 A.B に設定しているインスタンスと同じものを設定した上でエンコードすると以下のようになります )

b: &b
c: *b

の二通りがあり、 alias の名前を指定しない場合は、そのメンバに設定されているポインタの値から対応する anchor を探してきて決定するよということが伝えたかったです!

@lestrrat lestrrat mentioned this issue Oct 23, 2019
@goccy goccy closed this as completed in #3 Oct 23, 2019
charithe added a commit to charithe/go-yaml that referenced this issue May 14, 2024
nieomylnieja added a commit to nieomylnieja/go-yaml that referenced this issue Jul 5, 2024
goccy pushed a commit that referenced this issue Jul 16, 2024
…es handling (#457)

* fix scan double quote index progression

* fix: Correct root path handling (#2)

Ref: #456
charithe pushed a commit to charithe/go-yaml that referenced this issue Jul 22, 2024
…es handling (goccy#457)

* fix scan double quote index progression

* fix: Correct root path handling (goccy#2)

Ref: goccy#456
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants