commit
dcf677309d
49 changed files with 41 additions and 40 deletions
|
|
@ -32,7 +32,6 @@ type App struct {
|
|||
Runtime any
|
||||
}
|
||||
|
||||
|
||||
// Find locates a program on PATH and returns a Result containing the App.
|
||||
//
|
||||
// r := core.Find("node", "Node.js")
|
||||
|
|
@ -14,8 +14,8 @@ type ConfigVar[T any] struct {
|
|||
set bool
|
||||
}
|
||||
|
||||
func (v *ConfigVar[T]) Get() T { return v.val }
|
||||
func (v *ConfigVar[T]) Set(val T) { v.val = val; v.set = true }
|
||||
func (v *ConfigVar[T]) Get() T { return v.val }
|
||||
func (v *ConfigVar[T]) Set(val T) { v.val = val; v.set = true }
|
||||
func (v *ConfigVar[T]) IsSet() bool { return v.set }
|
||||
func (v *ConfigVar[T]) Unset() {
|
||||
v.set = false
|
||||
|
|
@ -224,7 +224,7 @@ func GeneratePack(pkg ScannedPackage) Result {
|
|||
return Result{b.String(), true}
|
||||
}
|
||||
|
||||
b.WriteString("import \"dappco.re/go/core/pkg/core\"\n\n")
|
||||
b.WriteString("import \"dappco.re/go/core\"\n\n")
|
||||
b.WriteString("func init() {\n")
|
||||
|
||||
// Pack groups (entire directories)
|
||||
|
|
@ -16,7 +16,7 @@ var (
|
|||
|
||||
// Lock is the DTO for a named mutex.
|
||||
type Lock struct {
|
||||
Name string
|
||||
Name string
|
||||
Mutex *sync.RWMutex
|
||||
}
|
||||
|
||||
|
|
@ -17,11 +17,11 @@ package core
|
|||
|
||||
// Service is a managed component with optional lifecycle.
|
||||
type Service struct {
|
||||
Name string
|
||||
Options Options
|
||||
OnStart func() Result
|
||||
OnStop func() Result
|
||||
OnReload func() Result
|
||||
Name string
|
||||
Options Options
|
||||
OnStart func() Result
|
||||
OnStop func() Result
|
||||
OnReload func() Result
|
||||
}
|
||||
|
||||
// serviceRegistry holds registered services.
|
||||
|
|
@ -13,9 +13,9 @@ import (
|
|||
// TaskState holds background task state.
|
||||
type TaskState struct {
|
||||
Identifier string
|
||||
Task Task
|
||||
Result any
|
||||
Error error
|
||||
Task Task
|
||||
Result any
|
||||
Error error
|
||||
}
|
||||
|
||||
// PerformAsync dispatches a task in a background goroutine.
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"io"
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ func TestGeneratePack_WithFiles_Good(t *testing.T) {
|
|||
os.MkdirAll(assetDir, 0755)
|
||||
os.WriteFile(assetDir+"/hello.txt", []byte("hello world"), 0644)
|
||||
|
||||
source := "package test\nimport \"dappco.re/go/core/pkg/core\"\nfunc example() {\n\t_, _ = core.GetAsset(\"mygroup\", \"hello.txt\")\n}\n"
|
||||
source := "package test\nimport \"dappco.re/go/core\"\nfunc example() {\n\t_, _ = core.GetAsset(\"mygroup\", \"hello.txt\")\n}\n"
|
||||
goFile := dir + "/test.go"
|
||||
os.WriteFile(goFile, []byte(source), 0644)
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -74,10 +74,12 @@ type mockTranslator struct {
|
|||
lang string
|
||||
}
|
||||
|
||||
func (m *mockTranslator) Translate(id string, args ...any) Result { return Result{"translated:" + id, true} }
|
||||
func (m *mockTranslator) SetLanguage(lang string) error { m.lang = lang; return nil }
|
||||
func (m *mockTranslator) Language() string { return m.lang }
|
||||
func (m *mockTranslator) AvailableLanguages() []string { return []string{"en", "de", "fr"} }
|
||||
func (m *mockTranslator) Translate(id string, args ...any) Result {
|
||||
return Result{"translated:" + id, true}
|
||||
}
|
||||
func (m *mockTranslator) SetLanguage(lang string) error { m.lang = lang; return nil }
|
||||
func (m *mockTranslator) Language() string { return m.lang }
|
||||
func (m *mockTranslator) AvailableLanguages() []string { return []string{"en", "de", "fr"} }
|
||||
|
||||
func TestI18n_WithTranslator_Good(t *testing.T) {
|
||||
c := New()
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ package core_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package scantest
|
||||
|
||||
import "dappco.re/go/core/pkg/core"
|
||||
import "dappco.re/go/core"
|
||||
|
||||
func example() {
|
||||
_, _ = core.GetAsset("mygroup", "myfile.txt")
|
||||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
. "dappco.re/go/core/pkg/core"
|
||||
. "dappco.re/go/core"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
Loading…
Add table
Reference in a new issue