-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (46 loc) · 987 Bytes
/
main.go
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"errors"
"fmt"
"github.com/google/wire"
)
func main() {
f, err := initializeDeps()
if err != nil {
panic(err.Error())
}
result, err := f.GoFetch()
fmt.Printf("Result: %s / %s", result, err)
}
// list of wire enabled dependencies
var wireSet = wire.NewSet(ProvideFetcher, ProvideCache)
// Providers
func ProvideFetcher(cache *Cache) *Fetcher {
return &Fetcher{
cache: cache,
}
}
func ProvideCache() (*Cache, error) {
cache := &Cache{}
err := cache.Start()
if err != nil {
return nil, err
}
return cache, nil
}
type Cache struct{}
func (c *Cache) Start() error {
return errors.New("not implemented yet")
}
func (c *Cache) Get(key string) (string, error) {
return "", errors.New("not implemented yet")
}
func (c *Cache) Set(key string, value string) error {
return errors.New("not implemented")
}
type Fetcher struct {
cache *Cache
}
func (f *Fetcher) GoFetch() (string, error) {
return "", errors.New("not implemented yet")
}