-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (31 loc) · 880 Bytes
/
main.go
File metadata and controls
41 lines (31 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
_ "modernc.org/sqlite"
)
type Sale struct {
Product int
Volume int
Date string
}
// String реализует метод интерфейса fmt.Stringer для Sale, возвращает строковое представление объекта Sale.
// Теперь, если передать объект Sale в fmt.Println(), то выведется строка, которую вернёт эта функция.
func (s Sale) String() string {
return fmt.Sprintf("Product: %d Volume: %d Date:%s", s.Product, s.Volume, s.Date)
}
func selectSales(client int) ([]Sale, error) {
var sales []Sale
// напишите код здесь
return sales, nil
}
func main() {
client := 208
sales, err := selectSales(client)
if err != nil {
fmt.Println(err)
return
}
for _, sale := range sales {
fmt.Println(sale)
}
}