Giter Club home page Giter Club logo

Comments (5)

goccy avatar goccy commented on May 14, 2024

Thank you for reporting!
This code is a bug, so I'll fix it.

from go-yaml.

goccy avatar goccy commented on May 14, 2024

@jeffalder

#151

Perhaps I could fix this issue with the above PR. Could you check it ?

from go-yaml.

jeffalder avatar jeffalder commented on May 14, 2024

Sorry it has taken me so long, I've been on holiday. I am going to work on validating this today.

You should know that I'm using https://github.com/yaml/yaml-test-suite to validate the changes. I can submit more issues based on what I find, if you'd like them. I know that the yaml-test-suite checks many corner cases which may not apply to general use cases.

from go-yaml.

jeffalder avatar jeffalder commented on May 14, 2024

Hi @goccy!

Thanks for your attention to this. I tried this branch with the YAML 1.1 example:

package main

import (
	"fmt"
	"github.com/goccy/go-yaml"
)

type Result struct {
	Sequence []string `yaml:"sequence"`
	Mapping map[string]string `yaml:"mapping"`
}

func main() {
	var result Result
	if err := yaml.Unmarshal([]byte(`
sequence:
- one
- two
mapping:
  ? sky
  : blue
  ? sea : green`), &result); err != nil {
		panic(err)
	}
	fmt.Println("good!")
	fmt.Println(result)
}

This panics:

panic: [6:5] unexpected key name
   3 | - one
   4 | - two
   5 | mapping:? sky
           ^
   7 |   : blue
   8 |   ? sea : green

This is the kind of case I would expect to be fixed in this issue. It doesn't look like #151 resolves this problem.

Note that #151 is a tiny improvement, though. v1.7.17 incorrectly renders % where #151 renders ?.

panic: [6:5] unexpected key name
   3 | - one
   4 | - two
   5 | mapping:% sky
           ^
   7 |   : blue
   8 |   % sea : green

from go-yaml.

jeffalder avatar jeffalder commented on May 14, 2024

You should know that go-yaml has some issues with this syntax as well, they're just different. go-yaml/yaml#611

from go-yaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.