Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
omris94 committed May 23, 2023
1 parent 468e0c2 commit a107141
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/shared/version/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0-local
33 changes: 33 additions & 0 deletions src/shared/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package version

import (
"os"
"sync"
)

var (
version string
once sync.Once
)

// Version returns the current version.
// It is implemented by reading a file instead of go:embed to avoid cache busting the Dockerfile before the build.
func Version() string {
once.Do(func() {
data, err := os.ReadFile("./shared/version/version")
if err == nil {
// only in development mode
version = string(data)
return
}

// only in production
data, err = os.ReadFile("./version")
if err != nil {
panic(err)
}
version = string(data)
})

return version
}

0 comments on commit a107141

Please sign in to comment.