mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-24 04:36:38 +00:00
acc95923da
* replace media workers with just runners.WorkerPool, move to state structure, use go-sched for global task scheduling * improved code comment * fix worker tryUntil function, update go-runners/go-sched * make preprocess functions package public, use these where possible to stop doubled up processing * remove separate emoji worker pool * limit calls to time.Now() during media preprocessing * use Processor{} to manage singular runtime of processing media * ensure workers get started when media manager is used * improved error setting in processing media, fix media test * port changes from processingmedia to processing emoji * finish code commenting * finish code commenting and comment-out client API + federator worker pools until concurrency worker pools replaced * linterrrrrrrrrrrrrrrr --------- Signed-off-by: kim <grufwub@gmail.com>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package debug
|
|
|
|
import (
|
|
_debug "runtime/debug"
|
|
)
|
|
|
|
// Run will only call fn if DEBUG is enabled.
|
|
func Run(fn func()) {
|
|
if DEBUG {
|
|
fn()
|
|
}
|
|
}
|
|
|
|
// BuildInfo will return a useful new-line separated build info string for current binary, setting name as given value.
|
|
func BuildInfo(name string) string {
|
|
// Read build info from current binary
|
|
build, ok := _debug.ReadBuildInfo()
|
|
if !ok {
|
|
return "name=" + name + "\n"
|
|
}
|
|
|
|
var flags, vcs, commit, time string
|
|
|
|
// Parse build information from BuildInfo.Settings
|
|
for i := 0; i < len(build.Settings); i++ {
|
|
switch build.Settings[i].Key {
|
|
case "-gcflags":
|
|
flags += ` -gcflags="` + build.Settings[i].Value + `"`
|
|
case "-ldflags":
|
|
flags += ` -ldflags="` + build.Settings[i].Value + `"`
|
|
case "-tags":
|
|
flags += ` -tags="` + build.Settings[i].Value + `"`
|
|
case "vcs":
|
|
vcs = build.Settings[i].Value
|
|
case "vcs.revision":
|
|
commit = build.Settings[i].Value
|
|
if len(commit) > 8 {
|
|
commit = commit[:8]
|
|
}
|
|
case "vcs.time":
|
|
time = build.Settings[i].Value
|
|
}
|
|
}
|
|
|
|
return "" +
|
|
"name=" + name + "\n" +
|
|
"vcs=" + vcs + "\n" +
|
|
"commit=" + commit + "\n" +
|
|
"version=" + build.Main.Version + "\n" +
|
|
"path=" + build.Path + "\n" +
|
|
"build=" + build.GoVersion + flags + "\n" +
|
|
"time=" + time + "\n"
|
|
}
|