Skip to content

Commit

Permalink
Allows compilation of code using debug.BuildInfo and show correct tin…
Browse files Browse the repository at this point in the history
…ygo version
  • Loading branch information
ldemailly committed Jul 16, 2024
1 parent f026422 commit 11ffebb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store
.vscode
go.work
go.work.sum

Expand Down
20 changes: 15 additions & 5 deletions src/runtime/debug/debug.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Package debug is a dummy package that is not yet implemented.
package debug

import "runtime"

// SetMaxStack sets the maximum amount of memory that can be used by a single
// goroutine stack.
//
Expand All @@ -27,16 +29,17 @@ func Stack() []byte {
//
// Not implemented.
func ReadBuildInfo() (info *BuildInfo, ok bool) {
return nil, false
return &BuildInfo{GoVersion: "tinygo" + runtime.Version()}, true
}

// BuildInfo represents the build information read from
// the running binary.
type BuildInfo struct {
Path string // The main package path
Main Module // The module containing the main package
Deps []*Module // Module dependencies
Settings []BuildSetting
GoVersion string // version of the Go toolchain that built the binary, e.g. "go1.19.2"
Path string // The main package path
Main Module // The module containing the main package
Deps []*Module // Module dependencies
Settings []BuildSetting
}

type BuildSetting struct {
Expand All @@ -58,3 +61,10 @@ type Module struct {
func SetGCPercent(n int) int {
return n
}

// String implements Stringer for BuildInfo.
//
// Not implemented.
func (bi *BuildInfo) String() string {
return "<build info placeholder>\n"
}

0 comments on commit 11ffebb

Please sign in to comment.