Skip to content

Commit

Permalink
framework/app: fix conflicing package names
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmueller committed Jul 2, 2022
1 parent 1a75ede commit b0f6fe2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
13 changes: 5 additions & 8 deletions framework/app/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,25 @@ type loader struct {
func (l *loader) Load() (state *State, err error) {
defer l.Recover2(&err, "app: unable to load state")
state = new(State)
state.Provider = l.loadProvider()
state.Flag = l.flag
l.imports.AddStd("os", "context", "errors")
l.imports.AddNamed("commander", "github.com/livebud/bud/package/commander")
l.imports.AddNamed("budclient", "github.com/livebud/bud/package/budclient")
l.imports.AddNamed("console", "github.com/livebud/bud/package/log/console")
l.imports.AddNamed("log", "github.com/livebud/bud/package/log")
l.imports.AddNamed("filter", "github.com/livebud/bud/package/log/filter")
l.imports.Add(l.module.Import("bud/internal/app/web"))
state.Provider = l.loadProvider()
state.Flag = l.flag
state.Imports = l.imports.List()
return state, nil
}

func (l *loader) loadProvider() *di.Provider {
jsVM := di.ToType("github.com/livebud/bud/package/js", "VM")
fn := &di.Function{
Name: "loadWeb",
Target: l.module.Import("bud", "program"),
Name: "loadWeb",
Imports: l.imports,
Target: l.module.Import("bud", "program"),
Params: []di.Dependency{
di.ToType("github.com/livebud/bud/package/log", "Interface"),
di.ToType("github.com/livebud/bud/package/gomod", "*Module"),
Expand All @@ -81,9 +82,5 @@ func (l *loader) loadProvider() *di.Provider {
// easily
l.Bail(fmt.Errorf("app: unable to wire. %s", err))
}
// Add imports
for _, im := range provider.Imports {
l.imports.AddNamed(im.Name, im.Path)
}
return provider
}
12 changes: 6 additions & 6 deletions framework/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2269,23 +2269,23 @@ func TestRedirectBack(t *testing.T) {
func TestSession(t *testing.T) {
is := is.New(t)
ctx := context.Background()
dir := t.TempDir()
dir := "_tmp"
td := testdir.New(dir)
td.Files["logz/logz.go"] = `
package logz
td.Files["log/log.go"] = `
package log
func New() *Logger { return &Logger{} }
type Logger struct {}
func (l *Logger) Info(msg string) {}
`
td.Files["session/session.go"] = `
package session
import "net/http"
import "app.com/logz"
func New(log *logz.Logger, w http.ResponseWriter, r *http.Request) *Session {
import "app.com/log"
func New(log *log.Logger, w http.ResponseWriter, r *http.Request) *Session {
return &Session{log, w, r}
}
type Session struct {
log *logz.Logger
log *log.Logger
w http.ResponseWriter
r *http.Request
}
Expand Down

0 comments on commit b0f6fe2

Please sign in to comment.