Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
b3da13a4
Commit
b3da13a4
authored
Nov 14, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
object links: Added text marshaling
parent
7bd7624c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
core/commands2/ls.go
core/commands2/ls.go
+8
-5
core/commands2/object.go
core/commands2/object.go
+7
-0
No files found.
core/commands2/ls.go
View file @
b3da13a4
...
...
@@ -82,11 +82,7 @@ it contains, with the following format:
if
len
(
output
)
>
1
{
s
+=
fmt
.
Sprintf
(
"%s:
\n
"
,
object
.
Hash
)
}
for
_
,
link
:=
range
object
.
Links
{
s
+=
fmt
.
Sprintf
(
"%s %v %s
\n
"
,
link
.
Hash
,
link
.
Size
,
link
.
Name
)
}
s
+=
marshalLinks
(
object
.
Links
)
if
len
(
output
)
>
1
{
s
+=
"
\n
"
}
...
...
@@ -97,3 +93,10 @@ it contains, with the following format:
},
Type
:
&
LsOutput
{},
}
func
marshalLinks
(
links
[]
Link
)
(
s
string
)
{
for
_
,
link
:=
range
links
{
s
+=
fmt
.
Sprintf
(
"%s %v %s
\n
"
,
link
.
Hash
,
link
.
Size
,
link
.
Name
)
}
return
s
}
core/commands2/object.go
View file @
b3da13a4
...
...
@@ -108,6 +108,13 @@ It outputs to stdout, and <key> is a base58 encoded multihash.
return
objectLinks
(
n
,
key
)
},
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
object
:=
res
.
Output
()
.
(
*
Object
)
marshalled
:=
marshalLinks
(
object
.
Links
)
return
[]
byte
(
marshalled
),
nil
},
},
Type
:
&
Object
{},
}
...
...
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