File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package manifest
2
2
3
3
import (
4
4
"encoding/json"
5
+ "runtime/debug"
5
6
"strings"
6
7
"time"
7
8
@@ -452,6 +453,11 @@ func (m *Metadata) UnmarshalJSON(b []byte) error {
452
453
return nil
453
454
}
454
455
456
+ // If you really don't want the version info in your manifest, you can blank this value.
457
+ var ToolkitVersionKey = "https://github.com/readium/go-toolkit/releases"
458
+
459
+ const toolkitRepo = "github.com/readium/go-toolkit"
460
+
455
461
func (m Metadata ) MarshalJSON () ([]byte , error ) {
456
462
j := make (map [string ]interface {})
457
463
if m .OtherMetadata != nil {
@@ -460,6 +466,22 @@ func (m Metadata) MarshalJSON() ([]byte, error) {
460
466
}
461
467
}
462
468
469
+ if ToolkitVersionKey != "" {
470
+ if info , ok := debug .ReadBuildInfo (); ok {
471
+ if info .Main .Path == toolkitRepo {
472
+ // This is the toolkit itself
473
+ j [ToolkitVersionKey ] = info .Main .Version
474
+ } else {
475
+ // This is a module that uses the toolkit
476
+ for _ , dep := range info .Deps {
477
+ if dep .Path == toolkitRepo {
478
+ j [ToolkitVersionKey ] = dep .Version
479
+ }
480
+ }
481
+ }
482
+ }
483
+ }
484
+
463
485
if m .Presentation != nil {
464
486
j ["presentation" ] = m .Presentation
465
487
}
You can’t perform that action at this time.
0 commit comments