Skip to content

Commit

Permalink
Automatically set SDKVersion (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
amh4r authored Mar 6, 2025
1 parent ddde6dd commit 8d71e77
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions consts.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package inngestgo

const (
SDKAuthor = "inngest"
SDKLanguage = "go"
SDKVersion = "0.8.0"
import (
"runtime/debug"
)

const (
SDKAuthor = "inngest"
SDKLanguage = "go"
SyncKindInBand = "in_band"
SyncKindOutOfBand = "out_of_band"
)
Expand All @@ -14,3 +16,34 @@ const (
defaultAPIOrigin = "https://api.inngest.com"
defaultEventAPIOrigin = "https://inn.gs"
)

var (
SDKVersion = ""
)

func init() {
readBuildInfo()
}

func readBuildInfo() {
info, ok := debug.ReadBuildInfo()
if !ok {
return
}

/*
Find and set the SDK version.
When imported into another project, its value will be something like
"v0.7.5-0.20250305172920-ddde6dd6f565".
When run within this project, it'll be "(devel)".
*/
const modulePath = "github.com/inngest/inngestgo"
for _, dep := range info.Deps {
if dep.Path == modulePath && dep.Version != "" {
SDKVersion = dep.Version
break
}
}
}

0 comments on commit 8d71e77

Please sign in to comment.