Commit 8feeb6a6 authored by Massimiliano Pippi's avatar Massimiliano Pippi

add convenience method to get the source in string format

parent 9c740866
......@@ -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
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment