Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ee7f7829
Commit
ee7f7829
authored
Feb 17, 2015
by
Vishnu Kannan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update yaml library.
parent
3043ae91
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
Godeps.json
Godeps/Godeps.json
+1
-1
yaml.go
Godeps/_workspace/src/github.com/ghodss/yaml/yaml.go
+6
-1
yaml_test.go
Godeps/_workspace/src/github.com/ghodss/yaml/yaml_test.go
+10
-2
No files found.
Godeps/Godeps.json
View file @
ee7f7829
...
...
@@ -103,7 +103,7 @@
},
{
"ImportPath"
:
"github.com/ghodss/yaml"
,
"Rev"
:
"
3bc1590d16074751993dd3b1a76e7a8d1a916a11
"
"Rev"
:
"
588cb435e59ee8b6c2795482887755841ad67207
"
},
{
"ImportPath"
:
"github.com/golang/glog"
,
...
...
Godeps/_workspace/src/github.com/ghodss/yaml/yaml.go
View file @
ee7f7829
...
...
@@ -46,7 +46,12 @@ func Unmarshal(y []byte, o interface{}) error {
func
JSONToYAML
(
j
[]
byte
)
([]
byte
,
error
)
{
// Convert the JSON to an object.
var
jsonObj
interface
{}
err
:=
json
.
Unmarshal
(
j
,
&
jsonObj
)
// We are using yaml.Unmarshal here (instead of json.Unmarshal) because the
// Go JSON library doesn't try to pick the right number type (int, float,
// etc.) when unmarshling to interface{}, it just picks float64
// universally. go-yaml does go through the effort of picking the right
// number type, so we can preserve number type throughout this process.
err
:=
yaml
.
Unmarshal
(
j
,
&
jsonObj
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
Godeps/_workspace/src/github.com/ghodss/yaml/yaml_test.go
View file @
ee7f7829
package
yaml
import
(
"fmt"
"math"
"reflect"
"strconv"
"testing"
)
type
MarshalTest
struct
{
A
string
B
int64
// Would like to test float64, but it's not supported in go-yaml.
// (See https://github.com/go-yaml/yaml/issues/83.)
C
float32
}
func
TestMarshal
(
t
*
testing
.
T
)
{
s
:=
MarshalTest
{
"a"
}
e
:=
[]
byte
(
"A: a
\n
"
)
f32String
:=
strconv
.
FormatFloat
(
math
.
MaxFloat32
,
'g'
,
-
1
,
32
)
s
:=
MarshalTest
{
"a"
,
math
.
MaxInt64
,
math
.
MaxFloat32
}
e
:=
[]
byte
(
fmt
.
Sprintf
(
"A: a
\n
B: %d
\n
C: %s
\n
"
,
math
.
MaxInt64
,
f32String
))
y
,
err
:=
Marshal
(
s
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment