@@ -37,26 +37,26 @@ import (
37
37
"github.com/bcmi-labs/arduino-modules/sketches"
38
38
)
39
39
40
- // A file saved on the virtual filesystem
40
+ // File is a file saved on the virtual filesystem.
41
41
type File struct {
42
- // The contents of the file, encoded in base64
42
+ // The contents of the file, encoded in base64.
43
43
Data * string `form:"data,omitempty" json:"data,omitempty" xml:"data,omitempty"`
44
- // The name of the file
44
+ // The name of the file.
45
45
Name string `form:"name" json:"name" xml:"name"`
46
46
}
47
47
48
- // A program meant to be uploaded onto a board
48
+ // Sketch is a program meant to be uploaded onto a board.
49
49
type Sketch struct {
50
- // The name of the sketch
50
+ // The name of the sketch.
51
51
Name string `form:"name" json:"name" xml:"name"`
52
- // The other files contained in the sketch
52
+ // The other files contained in the sketch.
53
53
Files []* File `form:"files,omitempty" json:"files,omitempty" xml:"files,omitempty"`
54
- // The folder path where the sketch is saved
54
+ // The folder path where the sketch is saved.
55
55
Folder * string `form:"folder,omitempty" json:"folder,omitempty" xml:"folder,omitempty"`
56
- // The main file of the sketch
56
+ // The main file of the sketch.
57
57
Ino * File `form:"ino" json:"ino" xml:"ino"`
58
58
Metadata * SketchMetadata `form:"metadata,omitempty" json:"metadata,omitempty" xml:"metadata,omitempty"`
59
- // The username of the owner of the sketch
59
+ // The username of the owner of the sketch.
60
60
Owner * string `form:"owner,omitempty" json:"owner,omitempty" xml:"owner,omitempty"`
61
61
// A private sketch is only visible to its owner.
62
62
Private bool `form:"private" json:"private" xml:"private"`
@@ -87,9 +87,8 @@ func ConvertFrom(sketch sketches.Sketch) *Sketch {
87
87
Types : sketch .Types ,
88
88
Metadata : ConvertMetadataFrom (sketch .Metadata ),
89
89
}
90
- ret .Files = make ([]* File , len (sketch .Files ))
91
- for i , f := range sketch .Files {
92
- if f .Name == "sketch.json" { //skipping sketch.json file, since it is Metadata of the sketch
90
+ for _ , f := range sketch .Files {
91
+ if f .Name == "sketch.json" { // Skipping sketch.json file, since it is Metadata of the sketch.
93
92
continue
94
93
}
95
94
_ , filePath := filepath .Split (f .Path )
@@ -99,10 +98,10 @@ func ConvertFrom(sketch sketches.Sketch) *Sketch {
99
98
}
100
99
101
100
data := base64 .StdEncoding .EncodeToString (content )
102
- ret .Files [ i ] = & File {
101
+ ret .Files = append ( ret . Files , & File {
103
102
Data : & data ,
104
103
Name : f .Name ,
105
- }
104
+ })
106
105
}
107
106
return & ret
108
107
}
@@ -113,6 +112,7 @@ type SketchMetadata struct {
113
112
IncludedLibs []* SketchMetadataLib `form:"included_libs,omitempty" json:"included_libs,omitempty" xml:"included_libs,omitempty"`
114
113
}
115
114
115
+ // ConvertMetadataFrom creates SketchMetadata object from sketches.Metadata.
116
116
func ConvertMetadataFrom (metadata * sketches.Metadata ) * SketchMetadata {
117
117
if metadata == nil {
118
118
return nil
@@ -137,22 +137,22 @@ func ConvertMetadataFrom(metadata *sketches.Metadata) *SketchMetadata {
137
137
return & ret
138
138
}
139
139
140
- // The board associated with the sketch
140
+ // SketchMetadataCPU is the board associated with the sketch.
141
141
type SketchMetadataCPU struct {
142
- // The fqbn of the board
142
+ // The fqbn of the board.
143
143
Fqbn * string `form:"fqbn,omitempty" json:"fqbn,omitempty" xml:"fqbn,omitempty"`
144
- // The name of the board
144
+ // The name of the board.
145
145
Name * string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"`
146
- // Requires an upload via network
146
+ // Requires an upload via network.
147
147
Network * bool `form:"network,omitempty" json:"network,omitempty" xml:"network,omitempty"`
148
- // The port of the board
148
+ // The port of the board.
149
149
Port * string `form:"port,omitempty" json:"port,omitempty" xml:"port,omitempty"`
150
150
}
151
151
152
- // A library associated with the sketch
152
+ // SketchMetadataLib is a library associated with the sketch.
153
153
type SketchMetadataLib struct {
154
- // The name of the library
154
+ // The name of the library.
155
155
Name * string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"`
156
- // The version of the library
156
+ // The version of the library.
157
157
Version * string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"`
158
158
}
0 commit comments