Could you please create a self-contained example where the
YAML is inside the code itself (use a back-quoted string containing the YAML)?

Also, could you please confirm the git commit hashes of the
YAML you're using on each platform?

If you're using a different version on each platform, please confirm
that your still see the difference in behaviour when you checkout
the same version on each.

  thanks,
    rog.

On 16 March 2018 at 07:24,  <dev.ys084...@gmail.com> wrote:
> Recently I started to use golang in project and I got one problem.
> The problem is the result of yaml.Unmarshal when I put invalid yaml is
> different between osX and linux.
>
> My environments are here
>
> macOS Sierra 10.12.6
> go version go1.10 darwin/amd64
>
> Linux version 3.10.0-693.11.6.el7.x86_64
> go version go1.10 linux/amd64
>
>
> This is my code I ran.
>
> invalid.yaml:
>
> ---------------------------------------------------------
>   namespace: aaaa
> name: bbbbbbb
>  description:  hyoooooooooooooooooooooooo
> maintainer: du...@example.com
> version: 1.1.1
> format::
>   :type: sample
>   file: ./foo.sh
>
> ---------------------------------------------------------
>
> main.go:
>
> ---------------------------------------------------------
>
> package main
>
> import (
> "fmt"
> "io/ioutil"
> "os"
>
> yaml "gopkg.in/yaml.v2"
> )
>
> type Sample struct {
> Namespace   string `yaml:"namespace"`
> Name        string `yaml:"name"`
> Description string `yaml:"description"`
> Maintainer  string `yaml:"maintainer"`
> Version     string `yaml:"version"`
> Format      struct {
> Type string `yaml:"type"`
> File string `yaml:"file"`
> } `yaml:"format"`
> }
>
> const (
> validYaml   = "./valid.yaml"
> invalidYaml = "./invalid.yaml"
> )
>
> func main() {
> data2, err := ioutil.ReadFile(invalidYaml)
> if err != nil {
> fmt.Println("It will not come here 2")
> os.Exit(1)
> }
> sample2 := &Sample{}
> err = yaml.Unmarshal(data2, sample2)
> if err != nil {
> fmt.Println("Should come here")
> os.Exit(0)
> }
> fmt.Println("It will not come here!!!!!!")
> os.Exit(1)
> }
>
> ---------------------------------------------------------
>
> Expect to see
> osX
> "Should come here"
>
> linux
> "Should come here"
>
> See instead
> osX
> "Should come here"
> linux
> "It will not come here!!!!!!"
>
> First time I thought this is a problem of library but the library looks like
> does not have the difference between linux and osX.
> So I ask this problem here.
>
>
> I hope to fix this problem.
>
> Thank you
>
> Yuichi
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to