forked from SierraSoftworks/sentry-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodules.go
42 lines (32 loc) · 860 Bytes
/
modules.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
package sentry
import "encoding/json"
// Modules allows you to specify the versions of various modules
// used by your application.
func Modules(moduleVersions map[string]string) Option {
if moduleVersions == nil {
return nil
}
return &modulesOption{moduleVersions}
}
type modulesOption struct {
moduleVersions map[string]string
}
func (o *modulesOption) Class() string {
return "modules"
}
func (o *modulesOption) Merge(old Option) Option {
if old, ok := old.(*modulesOption); ok {
moduleVersions := make(map[string]string, len(old.moduleVersions))
for k, v := range old.moduleVersions {
moduleVersions[k] = v
}
for k, v := range o.moduleVersions {
moduleVersions[k] = v
}
return &modulesOption{moduleVersions}
}
return o
}
func (o *modulesOption) MarshalJSON() ([]byte, error) {
return json.Marshal(o.moduleVersions)
}