urlshort icon indicating copy to clipboard operation
urlshort copied to clipboard

YAMLHandler does not work as expected

Open theMARxLENin opened this issue 5 years ago • 1 comments

I was following instructions in the video, wrote code exactly as Jon, but redirecting for "/urlshort" and "/urlshort-final" don't work. yaml.Unmarshal(yml, &pathUrls) returns only [{/urlshort }] for some reason. Does it have something to do with tags added to struct? In the video he added yaml tags automatically. I use VS Code and when I tried it struct became this:

type pathUrl struct {
	Path string `json:"path,omitempty"`
	URL  string `json:"url,omitempty"`
}

I changed it to yaml:"path" and yaml:"url", still does not work.

theMARxLENin avatar Jun 11 '20 07:06 theMARxLENin

To get the package, execute:

go get gopkg.in/yaml.v2 To import this package, add the following line to your code:

import "gopkg.in/yaml.v2" Refer to it as yaml.

yogeshnimangre007 avatar Oct 07 '20 11:10 yogeshnimangre007