Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
8feeb6a6
Commit
8feeb6a6
authored
Jul 08, 2019
by
Massimiliano Pippi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add convenience method to get the source in string format
parent
9c740866
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
arduino/sketch/sketch.go
arduino/sketch/sketch.go
+5
-0
arduino/sketch/sketch_test.go
arduino/sketch/sketch_test.go
+1
-0
No files found.
arduino/sketch/sketch.go
View file @
8feeb6a6
...
...
@@ -43,6 +43,11 @@ func NewItem(itemPath string) (*Item, error) {
return
&
Item
{
itemPath
,
source
},
nil
}
// GetSourceStr returns the Source contents in string format
func
(
i
*
Item
)
GetSourceStr
()
string
{
return
string
(
i
.
Source
)
}
// ItemByPath implements sort.Interface for []Item based on
// lexicographic order of the path string.
type
ItemByPath
[]
*
Item
...
...
arduino/sketch/sketch_test.go
View file @
8feeb6a6
...
...
@@ -30,6 +30,7 @@ func TestNewItem(t *testing.T) {
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
sketchItem
,
item
.
Path
)
assert
.
Equal
(
t
,
[]
byte
(
`#include <testlib.h>`
),
item
.
Source
)
assert
.
Equal
(
t
,
"#include <testlib.h>"
,
item
.
GetSourceStr
())
item
,
err
=
sketch
.
NewItem
(
"doesnt/exist"
)
assert
.
Nil
(
t
,
item
)
...
...
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