github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/sys/builtin/impl_modules.go (about) 1 /* 2 * Copyright (c) 2020-present unTill Pro, Ltd. 3 * @author Denis Gribanov 4 */ 5 6 package builtin 7 8 import ( 9 "bytes" 10 "context" 11 "fmt" 12 "runtime/debug" 13 14 "github.com/voedger/voedger/pkg/appdef" 15 "github.com/voedger/voedger/pkg/istructs" 16 istructsmem "github.com/voedger/voedger/pkg/istructsmem" 17 ) 18 19 func provideQryModules(cfg *istructsmem.AppConfigType, buildInfo *debug.BuildInfo) { 20 cfg.Resources.Add(istructsmem.NewQueryFunction( 21 appdef.NewQName(appdef.SysPackage, "Modules"), 22 provideQryModulesExec(buildInfo), 23 )) 24 } 25 26 type qryModulesRR struct { 27 istructs.NullObject 28 modules string 29 } 30 31 func provideQryModulesExec(buildInfo *debug.BuildInfo) istructsmem.ExecQueryClosure { 32 return func(ctx context.Context, args istructs.ExecQueryArgs, callback istructs.ExecQueryCallback) (err error) { 33 sb := bytes.NewBufferString("") 34 for _, mod := range buildInfo.Deps { 35 sb.WriteString(fmt.Sprintf("path: %s version: %s\n", mod.Path, mod.Version)) 36 } 37 return callback(&qryModulesRR{modules: sb.String()}) 38 } 39 }