livebud / bud Goto Github PK
View Code? Open in Web Editor NEWThe Full-Stack Web Framework for Go
License: MIT License
The Full-Stack Web Framework for Go
License: MIT License
I ran:
bud new controller associations index show
bud new controller academies index show
bud new controller associations/academies index show
This laid out out the appropriate controllers in the /controller directory. However, I'm getting an error
bud/.app/controller/controller.go:9:2: imported and not used: "bud-test/controller/associations/academies" as academies1
looking at bud/.app/controller/controller.go, we can see that bud-test/controller/associations/academies
is imported at as academies1
but that import isn't used. I can't delete it because the framework automatically generates it again.
Is there a correct way to create nested controllers like this?
package controller
import (
view "bud-test/bud/.app/view"
controller "bud-test/controller"
academies "bud-test/controller/academies"
members "bud-test/controller/academies/members"
associations "bud-test/controller/associations"
academies1 "bud-test/controller/associations/academies"
users "bud-test/controller/users"
request "github.com/livebud/bud/runtime/controller/request"
response "github.com/livebud/bud/runtime/controller/response"
http "net/http"
)
// Controller struct
type Controller struct {
Index *IndexAction
Show *ShowAction
Academies *AcademiesController
Associations *AssociationsController
Users *UsersController
}
// IndexAction struct
type IndexAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (i *IndexAction) Key() string {
return "/index"
}
// Path is the default RESTful path to this action
func (i *IndexAction) Path() string {
return "/"
}
// Method is the default RESTful method of this action
func (i *IndexAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (i *IndexAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
i.handler(r).ServeHTTP(w, r)
}
// Handler function
func (i *IndexAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
controllerController := loadController()
fn := controllerController.Index
// Call the controller
stories, err := fn(
httpRequest.Context(),
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: i.View.Handler("/", map[string]interface{}{"stories": stories}),
JSON: response.JSON(stories),
}
}
// ShowAction struct
type ShowAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (s *ShowAction) Key() string {
return "/show"
}
// Path is the default RESTful path to this action
func (s *ShowAction) Path() string {
return "/:id"
}
// Method is the default RESTful method of this action
func (s *ShowAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (s *ShowAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.handler(r).ServeHTTP(w, r)
}
// Handler function
func (s *ShowAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
ID int `json:"id,omitempty"`
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
controllerController := loadController()
fn := controllerController.Show
// Call the controller
story, err := fn(
httpRequest.Context(),
in.ID,
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: s.View.Handler("/:id", map[string]interface{}{"story": story}),
JSON: response.JSON(story),
}
}
// Controller struct
type AcademiesController struct {
Index *AcademiesIndexAction
Show *AcademiesShowAction
Members *AcademiesMembersController
}
// AcademiesIndexAction struct
type AcademiesIndexAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (i *AcademiesIndexAction) Key() string {
return "/academies/index"
}
// Path is the default RESTful path to this action
func (i *AcademiesIndexAction) Path() string {
return "/academies"
}
// Method is the default RESTful method of this action
func (i *AcademiesIndexAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (i *AcademiesIndexAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
i.handler(r).ServeHTTP(w, r)
}
// Handler function
func (i *AcademiesIndexAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
academiesController := loadAcademiesController()
fn := academiesController.Index
// Call the controller
academies, err := fn(
httpRequest.Context(),
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: i.View.Handler("/academies", map[string]interface{}{"academies": academies}),
JSON: response.JSON(academies),
}
}
// AcademiesShowAction struct
type AcademiesShowAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (s *AcademiesShowAction) Key() string {
return "/academies/show"
}
// Path is the default RESTful path to this action
func (s *AcademiesShowAction) Path() string {
return "/academies/:id"
}
// Method is the default RESTful method of this action
func (s *AcademiesShowAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (s *AcademiesShowAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.handler(r).ServeHTTP(w, r)
}
// Handler function
func (s *AcademiesShowAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
ID int `json:"id,omitempty"`
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
academiesController := loadAcademiesController()
fn := academiesController.Show
// Call the controller
academy, err := fn(
httpRequest.Context(),
in.ID,
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: s.View.Handler("/academies/:id", map[string]interface{}{"academy": academy}),
JSON: response.JSON(academy),
}
}
// Controller struct
type AcademiesMembersController struct {
Index *AcademiesMembersIndexAction
Show *AcademiesMembersShowAction
}
// AcademiesMembersIndexAction struct
type AcademiesMembersIndexAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (i *AcademiesMembersIndexAction) Key() string {
return "/academies/members/index"
}
// Path is the default RESTful path to this action
func (i *AcademiesMembersIndexAction) Path() string {
return "/academies/:academy_id/members"
}
// Method is the default RESTful method of this action
func (i *AcademiesMembersIndexAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (i *AcademiesMembersIndexAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
i.handler(r).ServeHTTP(w, r)
}
// Handler function
func (i *AcademiesMembersIndexAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
membersController := loadAcademiesMembersController()
fn := membersController.Index
// Call the controller
members, err := fn(
httpRequest.Context(),
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: i.View.Handler("/academies/:academy_id/members", map[string]interface{}{"members": members}),
JSON: response.JSON(members),
}
}
// AcademiesMembersShowAction struct
type AcademiesMembersShowAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (s *AcademiesMembersShowAction) Key() string {
return "/academies/members/show"
}
// Path is the default RESTful path to this action
func (s *AcademiesMembersShowAction) Path() string {
return "/academies/:academy_id/members/:id"
}
// Method is the default RESTful method of this action
func (s *AcademiesMembersShowAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (s *AcademiesMembersShowAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.handler(r).ServeHTTP(w, r)
}
// Handler function
func (s *AcademiesMembersShowAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
ID int `json:"id,omitempty"`
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
membersController := loadAcademiesMembersController()
fn := membersController.Show
// Call the controller
member, err := fn(
httpRequest.Context(),
in.ID,
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: s.View.Handler("/academies/:academy_id/members/:id", map[string]interface{}{"member": member}),
JSON: response.JSON(member),
}
}
// Controller struct
type AssociationsController struct {
Index *AssociationsIndexAction
Show *AssociationsShowAction
Academies *AssociationsAcademiesController
}
// AssociationsIndexAction struct
type AssociationsIndexAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (i *AssociationsIndexAction) Key() string {
return "/associations/index"
}
// Path is the default RESTful path to this action
func (i *AssociationsIndexAction) Path() string {
return "/associations"
}
// Method is the default RESTful method of this action
func (i *AssociationsIndexAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (i *AssociationsIndexAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
i.handler(r).ServeHTTP(w, r)
}
// Handler function
func (i *AssociationsIndexAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
associationsController := loadAssociationsController()
fn := associationsController.Index
// Call the controller
associations, err := fn(
httpRequest.Context(),
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: i.View.Handler("/associations", map[string]interface{}{"associations": associations}),
JSON: response.JSON(associations),
}
}
// AssociationsShowAction struct
type AssociationsShowAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (s *AssociationsShowAction) Key() string {
return "/associations/show"
}
// Path is the default RESTful path to this action
func (s *AssociationsShowAction) Path() string {
return "/associations/:id"
}
// Method is the default RESTful method of this action
func (s *AssociationsShowAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (s *AssociationsShowAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.handler(r).ServeHTTP(w, r)
}
// Handler function
func (s *AssociationsShowAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
ID int `json:"id,omitempty"`
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
associationsController := loadAssociationsController()
fn := associationsController.Show
// Call the controller
association, err := fn(
httpRequest.Context(),
in.ID,
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: s.View.Handler("/associations/:id", map[string]interface{}{"association": association}),
JSON: response.JSON(association),
}
}
// Controller struct
type AssociationsAcademiesController struct {
Index *AssociationsAcademiesIndexAction
Show *AssociationsAcademiesShowAction
}
// AssociationsAcademiesIndexAction struct
type AssociationsAcademiesIndexAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (i *AssociationsAcademiesIndexAction) Key() string {
return "/associations/academies/index"
}
// Path is the default RESTful path to this action
func (i *AssociationsAcademiesIndexAction) Path() string {
return "/associations/:association_id/academies"
}
// Method is the default RESTful method of this action
func (i *AssociationsAcademiesIndexAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (i *AssociationsAcademiesIndexAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
i.handler(r).ServeHTTP(w, r)
}
// Handler function
func (i *AssociationsAcademiesIndexAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
academiesController := loadAssociationsAcademiesController()
fn := academiesController.Index
// Call the controller
academies, err := fn(
httpRequest.Context(),
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: i.View.Handler("/associations/:association_id/academies", map[string]interface{}{"academies": academies}),
JSON: response.JSON(academies),
}
}
// AssociationsAcademiesShowAction struct
type AssociationsAcademiesShowAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (s *AssociationsAcademiesShowAction) Key() string {
return "/associations/academies/show"
}
// Path is the default RESTful path to this action
func (s *AssociationsAcademiesShowAction) Path() string {
return "/associations/:association_id/academies/:id"
}
// Method is the default RESTful method of this action
func (s *AssociationsAcademiesShowAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (s *AssociationsAcademiesShowAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.handler(r).ServeHTTP(w, r)
}
// Handler function
func (s *AssociationsAcademiesShowAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
ID int `json:"id,omitempty"`
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
academiesController := loadAssociationsAcademiesController()
fn := academiesController.Show
// Call the controller
academy, err := fn(
httpRequest.Context(),
in.ID,
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: s.View.Handler("/associations/:association_id/academies/:id", map[string]interface{}{"academy": academy}),
JSON: response.JSON(academy),
}
}
// Controller struct
type UsersController struct {
Index *UsersIndexAction
Show *UsersShowAction
}
// UsersIndexAction struct
type UsersIndexAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (i *UsersIndexAction) Key() string {
return "/users/index"
}
// Path is the default RESTful path to this action
func (i *UsersIndexAction) Path() string {
return "/users"
}
// Method is the default RESTful method of this action
func (i *UsersIndexAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (i *UsersIndexAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
i.handler(r).ServeHTTP(w, r)
}
// Handler function
func (i *UsersIndexAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
usersController := loadUsersController()
fn := usersController.Index
// Call the controller
users, err := fn(
httpRequest.Context(),
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: i.View.Handler("/users", map[string]interface{}{"users": users}),
JSON: response.JSON(users),
}
}
// UsersShowAction struct
type UsersShowAction struct {
View *view.Server
}
// Key is a unique identifier of this action
func (s *UsersShowAction) Key() string {
return "/users/show"
}
// Path is the default RESTful path to this action
func (s *UsersShowAction) Path() string {
return "/users/:id"
}
// Method is the default RESTful method of this action
func (s *UsersShowAction) Method() string {
return "GET"
}
// ServeHTTP fn
func (s *UsersShowAction) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.handler(r).ServeHTTP(w, r)
}
// Handler function
func (s *UsersShowAction) handler(httpRequest *http.Request) http.Handler {
// Define the input struct
var in struct {
ID int `json:"id,omitempty"`
}
// Unmarshal the request body
if err := request.Unmarshal(httpRequest, &in); err != nil {
return &response.Format{
JSON: response.Status(400).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
usersController := loadUsersController()
fn := usersController.Show
// Call the controller
user, err := fn(
httpRequest.Context(),
in.ID,
)
if err != nil {
return &response.Format{
JSON: response.Status(500).Set("Content-Type", "application/json").JSON(map[string]string{"error": err.Error()}),
}
}
// Respond
return &response.Format{
HTML: s.View.Handler("/users/:id", map[string]interface{}{"user": user}),
JSON: response.JSON(user),
}
}
func loadAcademiesController() *academies.Controller {
academiesController := &academies.Controller{}
return academiesController
}
func loadAcademiesMembersController() *members.Controller {
membersController := &members.Controller{}
return membersController
}
func loadAssociationsAcademiesController() *academies.Controller {
academiesController := &academies.Controller{}
return academiesController
}
func loadAssociationsController() *associations.Controller {
associationsController := &associations.Controller{}
return associationsController
}
func loadController() *controller.Controller {
controllerController := &controller.Controller{}
return controllerController
}
func loadUsersController() *users.Controller {
usersController := &users.Controller{}
return usersController
}
Hello, After I bud build the project, I remove the *.go and go.mod source files. run ./bud/app in the terminal, but it output the error: unable to find go.mod: file does not exist in "/Users/Works/news"
---- for exmaple input the command in the terminal
news % ./bud/app
unable to find go.mod: file does not exist in "/Users/Works/news"
Why the app is running and it needs to depend go.mod?
I tried running the installer in Termux, please add termux support XD.
livebud/bud: platform linux/arm64 is not supported. Make sure this script is up-to-date and file request at https://github.com/livebud/bud/issues/new
In v0.1.5, there were some breaking changes to the runtime. If you had an existing application and ran bud run
, you'd get the following error:
| conjure: generate "bud/.cli/program/program.go". program: unable to wire > di: unable to wire "github.com/livebud/basic/bud/.cli/program".loadCLI function. parser: unable to import package "bud/.cli/command". conjure: generate "bud/.cli/command/command.go". command: unable to parse. di: unable to wire "github.com/livebud/basic/bud/.cli/command".loadGenerator function. di: unclear how to provide "github.com/livebud/bud/runtime/bud".*Flag.
To fix this, you'll need to run go get -u github.com/livebud/[email protected]
to get the current runtime.
The runtime and the CLI are designed to be in lockstep with each other. The CLI should check and update the runtime when it's out of step.
There's a couple issues here that need to be fixed:
For some reason the hot reload port wasn't released, despite the application port being released. I'm not able to reproduce this behavior at the moment, so let's just keep an eye on it for now.
Nil pointer panic on *exe.Close
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xa0 pc=0x148aa70]
goroutine 66 [running]:
github.com/livebud/bud/package/exe.(*Cmd).Close(0x0)
/Users/m/dev/src/github.com/livebud/bud/package/exe/command.go:24 +0x70
panic({0x151a1a0, 0x19de710})
/usr/local/go/src/runtime/panic.go:838 +0x207
os/exec.(*Cmd).Wait(0x173cec0?)
/usr/local/go/src/os/exec/exec.go:499 +0x18
github.com/livebud/bud/package/exe.(*Cmd).Wait(...)
/Users/m/dev/src/github.com/livebud/bud/package/exe/command.go:39
github.com/livebud/bud/runtime/command/run.(*Command).startApp(0xc000256f60, {0x173cec0?, 0xc00024d300}, 0xc000243490)
/Users/m/dev/src/github.com/livebud/bud/runtime/command/run/run.go:115 +0x3c5
github.com/livebud/bud/runtime/command/run.(*Command).Run.func2()
/Users/m/dev/src/github.com/livebud/bud/runtime/command/run/run.go:37 +0x29
golang.org/x/sync/errgroup.(*Group).Go.func1()
/Users/m/dev/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:74 +0x64
created by golang.org/x/sync/errgroup.(*Group).Go
/Users/m/dev/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:71 +0xa5
The problem is that process
is nil for some reason when calling the following:
bud/runtime/command/run/run.go
Line 75 in 63900d2
Need a better error for unable to start the live reload server. Perhaps:
fmt.Errorf("Error starting the live reload server on %s: %w", address, err)
Eventually, I'd like to find a free port and propagate the change accordingly, but for now, I think we just supply a better error.
bud/runtime/command/run/run.go
Lines 117 to 120 in 63900d2
func (c *Command) startHot(ctx context.Context, hotServer *hot.Server) error {
// TODO: host should be dynamic
+ return fmt.Errorf("failed to listen")
- return hotServer.ListenAndServe(ctx, "127.0.0.1:35729")
}
go run main.go -C examples/hn run
Hi @matthewmueller, First of all, Thanks for building this bud !!
I thought of learning this by giving a try, so here is an understanding question:
So, I was able to install the bud, create the app, was able to see bud home page with the nice splash. Now I tried this command bud new controller photos show index
and then was able to see the index page in the browser with the nice title. All good until here.
Now, I wanted to rename the photos
to photo
, so I thought of deleting the folders/files and retype bud new...
and deleted the photos
directory present in both the controllers
& views
directory & did go mod tidy
and it ended up showing this error:
โฏ go mod tidy
go: finding module for package github.com/kishorevaishnav/shinyroll/controller/photos
github.com/kishorevaishnav/shinyroll/bud imports
github.com/kishorevaishnav/shinyroll/bud/.app/program imports
github.com/kishorevaishnav/shinyroll/bud/.app/web imports
github.com/kishorevaishnav/shinyroll/bud/.app/controller imports
github.com/kishorevaishnav/shinyroll/controller/photos: no matching versions for query "latest"
I tried to find the word photos in the entire directory and couldn't find any word of it, rather than fixing this or reverting the code, would like to understand where is this cached? & what is the logic behind it. If you can give me some insight and direct me some files to understand will be of great help.
P.S. Apologize if this shouldn't be posted here - not sure where to ask these kind of questions.
I've been extremely impressed by and interested in but (great work @matthewmueller!!) and I wanted to begin contributing to an interesting bug that I saw in the issues. So I cloned bud and was following the instructions in Contributing.md, but I ran into an error when running make install.
OS: Windows 10
Go Version: 1.18.2
Node.js Version: 16.14.0
I was doing install script in my macbook air m1
$ curl -sf curl https://raw.githubusercontent.com/livebud/bud/main/install.sh | sh
then I got this error
livebud/bud: platform darwin/arm64 is not supported. Make sure this script is up-to-date and file request at https://github.com/livebud/bud/issues/new
livebud.com does not resolve
Whenever a request doesn't match the controller's signature, we should return a 400 Bad Request
with a helpful error:
For example, given the following signature:
func (c *Controller) Create(name, email string) {}
With the following request map:
{
"name": 123
}
We should return the following response:
{
"error": "name must be a string and email can't be blank",
"fields": {
"name": "must be a string",
"email": "can't be blank"
}
}
Errors should also be helpful for nested inputs:
{
"error": "version can't be blank",
"fields": {
"op.params[1].version": "can't be blank"
}
}
Thanks for making bud!
I must be doing something wrong here. I'd like to scaffold create, read, update and delete actions.
It seems like only index and show are implemented, is that correct? (when running bud new controller ...
Right now we have entrypoints that have the following format: bud/view/{controller}/\_{action}.{ext}
, so for bud/view/index.svelte
, the entrypoint would look like bud/view/_index.svelte
.
This was nice for understanding the mapping, but doesn't play well with tools that use the extension to determine the content-type, since those served svelte files are actually javascript.
Let's change this, perhaps:
.bud/view/index.entry.svelte.js
: entrypoint for view/index.svelte
(includes hydration + event sourcing).bud/view/index.svelte.js
: compiled view/index.svelte
componentI created nested views with running the command.
bud new controller post index show
It generated the files fine but when I opened the /post
URL, the td
element didn't include prefix the URL with the /post
instead it relative to the root.
I'm not sure whether I was suppose to update the URL manually or not as it's a minor thing.
Hi @matthewmueller, I was thinking of creating a Django like framework in golang too. I came across your project and it has almost everything that I was looking for.
I would like you to know I will be happy to help this project grow. Please do let me know what helps do you need.
Given the following plugin with the module path plugin.com
bud-admin/
controller/
admin/
admin.go
plugin.go
go.mod
And an application with the following module path app.com
, if you run bud build
, you'll get the following:
error: mod: unable to resolve directory for package path "app.com/controller/admin": stat
controller/admin: no such file or directory
While bud has successfully bundled the admin controller from plugin.com
into app.com
, it's messed up the import paths:
app.com/controller/admin
plugin.com/controller/admin
Many of us try to keep off software installed via curl | sh
.
Not sure if it's related but localStorage
, window
, document
, setInterval
, etc have a weird behavior too.
view: render error ReferenceError: setInterval is not defined
when wrapped inside a if (typeof document != "undefined")
or anything that v8 will appreciate, everything is fine, console.log
included
Originally posted by @ldlac in #87 (comment)
For example,
func (c *Controller) Create() {
// do something
}
These functions should return 204 No Content
if successful.
Currently when there's a server-side rendering error, that you subsequently fix, you'll need to refresh the page again. This is likely because the event source isn't hooked up to that error yet.
Steps to reproduce:
<script>
export let _string = ""
a.b = 'c'
</script>
<h1>{_string}</h1>
<style>
h1 {
background: blue;
padding: 20px;
color: white;
}
</style>
package controller
type Controller struct {
}
func (c *Controller) Index() string {
return "hello world."
}
func (c *Controller) Show(id string) string {
return "shows/" + id
}
And you'll see something like ReferenceError: a is not defined
in the browser. Even if you fix the problem in Svelte, it won't refresh.
Need to make this happen! Two requests so far from @kuldar and @sid405 ๐
From Sidd:
I was able to get Bud running under Rosetta 2 by starting a Rosetta2 shell:
arch -arch x86_64 zsh
. I have this aliased torosetta
because I need it every once in a while.
So how do I debug the project?
when i run this command in windows11's terminal:
curl -sf https://raw.githubusercontent.com/livebud/bud/main/install.sh | sh
sh: uname_os_check: internal error 'MINGW64_NT-10.0-25115' got converted to 'mingw64_nt-10.0-25115' which is not a GOOS value. Please file bug at https://github.com/client9/shlib
Will it suport windows?
I have made a new controller user bud new controller users index show
. This scaffolded the controller and view as expected.
I then modified the controller to :
import (
context "context"
)
type Controller struct {
// Dependencies...
}
// User struct
type User struct {
id int
firstName string
lastName string
}
// Index of users
// GET /users
func (c *Controller) Index(ctx context.Context) (users []*User, err error) {
var u1 = User{1, "firstname", "lastname"}
users = append(users, &u1)
return users, err
}
// Show user
// GET /users/:id
func (c *Controller) Show(ctx context.Context, id int) (user *User, err error) {
return &User{}, nil
}
When I go to http://127.0.0.1:3000/users
, I only see the scaffolded header "User Index". Unsure of what what happening, since the table wasn't displayed, I added another header:
<h1>{JSON.stringify(users)}</h1>
to inspect the content of the users
variable inside of index.svelte
This displays with
[{}]
This suggests that an object is being serialized, but the contents of the objects are being discarded somewhere.
Am I doing something wrong?
โ bud-hello bud version
bud: 0.1.4
svelte: 3.47.0
react: 18.0.0
โ bud-hello bud run
| Listening on http://127.0.0.1:3000
# github.com/livebud/bud/package/scaffold
../../../go/pkg/mod/github.com/livebud/[email protected]/package/scaffold/template.go:28:8: undefined: any
note: module requires Go 1.18
โ bud-hello go version
go version go1.17.10 darwin/amd64
According to the demo video, bud is agnostic to front end frameworks, but currently only ships with Svelte and planned to ship with React in the future. Just curious if there are plans to ship with Vue as a friend of mine and I are currently working on a Go/Vue project
It would be great to have this repo in the AUR as bud-bin
. I'm happy to publish it there and maintain it. Or would you prefer to do it yourself?
I'm particularly partial to https://vitejs.dev/guide/#trying-vite-online for my react projects as the vite runner is "blazingly fast" compared to any alternatives.
Windows support is currently blocked by:
Bud's compiler will also transition to using Go plugins, which also do not have Windows support yet:
I haven't tested it yet, but you should be able to use Bud with the Windows Subsystem for Linux (WSL).
If you get this working, please let us know how!
Notion docs show
# Clear the build cache
bud tool cache clear
cli uses clean
instead of clear
$ bud version
bud: 0.1.1
svelte: 3.47.0
react: 18.0.0
$ bud tool cache
Usage:
cache [command]
Commands:
clean Clear the cache directory
Notion is a dumpster fire, you have full access to github pages and a million other things, please setup something actually usable. Docusaurus, Jekyll, Hugo and a bunch of other SSGs will create docs (can even be searchable) from markdown source (which I'm p sure you can export from Notion).
I've just been attempting to try out bud, but ran into issues before I could get going.
Granted, I've not got far into learning Go, I thought bud would help to give me a gentler start to creating a web app, so I may be missing something that is considered "basic Go knowledge".
I've followed your example to get going:
and I get presented with the following:
~/code/go/src/github.com/techwilk/test-bud$ bud run
| Listening on http://127.0.0.1:3000
| conjure: generate "bud/.cli/program/program.go" > program: unable to wire > di: unable to find definition for param "github.com/livebud/bud/runtime/bud".*Flag within "github.com/techwilk/test-bud/bud/.cli/command".*CLI > stat /home/user/go:/home/user/code/go/pkg/mod/github.com/livebud/[email protected]: no such file or directory
I've previously had Go 1.17, but upgraded to 1.18.2 which didn't change anything.
/:id
, controller.Show)Been using go for a while and have been looking for a framework like bud for a while.
I installed bud using the install script, then when trying to create a new project using bud create hello
the installed runs some things happen however the cli get stuck ( see screenshot).
No new folders appear inside of the directory and the terminal is stuck.
Bud's impressive and I understand it's just 0.1
, so it would be highly ambitious(and very, very early) to expect a very good documentation, blog and example ecosystem. But, just to give it a consideration as a very low priority task - will it be possible for you to consider adding an example with DI(Env, DB, etc.) ? I'm not a seasoned Go dev, and I think seeing a good example with DI can help anybody like me, even the developers that Bud might inevitably attract due to its affinity towards modern FE frameworks.
Watched the demo and it was pretty good!
I am curious if you've thought about adding a way of rendering the views server-side instead of using Svelte? For example, using Go's templating system. I realize you lose out on the component capabilities of today's FE frameworks, but as someone who prefers server-side rendered apps, I think this would be a good feature to support. As mentioned it can be another variation that bud supports in addition to svelte, React and others.
Thanks!
Given the following plugin with the module path plugin.com
bud-admin/
view/
index.svelte
plugin.go
go.mod
And an application with the following module path app.com
, if you run bud build
, you'll get the following:
ssr_test.go:293: err: conjure: generate "bud/view/_ssr.js" > โ [ERROR] Could not resolve "./view/index.svelte"
svelte:./bud/view/index.svelte:2:28:
2 โ import ViewIndexSvelte from "./view/index.svelte"
โต ~~~~~~~~~~~~~~~~~~~~~
I assume this error is because ESBuild doesn't yet support virtual file paths, so it's one of the few places in the codebase where we rely on the underlying filesystem. The actual location of the index view is in the plugin.com
module's view/
not your app.com
's view/
.
If that's the case, the ESBuild resolver should be updated to use the virtual filesystem.
When I did 'bud create ff-bud', I got this error:
| rename /tmp/bud-create-3425471412 ff-bud: invalid cross-device link
Possibly because /tmp is different partition than the current directory. Rename will work only in same partition?
I'm following along the HackerNews video and am encountering build issues.
I'm performing the following steps
mkdir bud-test
cd bud-test
bud create .
bud build
bud run
bud new controller stories:/ index show
When I go to the webpage I'm given the following error
| conjure: generate "bud/.app/view/view.go" > โ [ERROR] Could not resolve "svelte/internal"
view/index.svelte:7:7:
7 โ } from "svelte/internal";
โต ~~~~~~~~~~~~~~~~~
You can mark the path "svelte/internal" as external to exclude it from the
bundle, which will remove this error.
โ [ERROR] Could not resolve "svelte/internal"
view/show.svelte:2:51:
2 โ import { create_ssr_component, each, escape } from "svelte/internal";
โต ~~~~~~~~~~~~~~~~~
You can mark the path "svelte/internal" as external to exclude it from the
bundle, which will remove this error.
Here are some details about my environment
bud version
โ bud-test bud version
bud: 0.1.4
svelte: 3.47.0
react: 18.0.0
go version
go version go1.18.3 darwin/arm64
bud new controller hello:/ index show
bud run
console.log(hellos);
in the script tag (index.svelte)gob: bad data: field numbers out of bounds
More details:
console.log(hellos);
doesn't fix the problem unless I bud run
againOS: Arch linux
Go: v1.18.2
Node: v14.19.3
bud: 0.1.4
Edit: app made with bud build
works normally.
I'm attempting to implement persistence. So I create a new folder models
. Write a struct. Update the controllers to use that new struct instead of the autogenerated one. Then run bud run
. But bud errors out with
bud/.app/controller/controller.go:10:2: imported and not used: "github/donovanrost/bud-test/models"
I don't think that bud needs to do any code generation with this package. Is there a way to tell bud to ignore it?
bud new controller hello:/ index
fmt.Println("anything")
in the controllerfunc (c *Controller) Index(ctx context.Context) (hellos []*Hello, err error) {
fmt.Println("Hello world")
return []*Hello{}, nil
}
bud run
Hello world
message is printed.Hello world
message prompted in the terminal. Don't change anything and save one/multiple times controller.go, Hello world
s will be printed out (it's inconsistent, sometime nothing is printed out)I had to disable two tests:
bud/internal/testdir/testdir_test.go
Line 64 in 7bcf01d
bud/internal/testdir/testdir_test.go
Line 109 in 7bcf01d
to avoid flakiness in CI. The error that occasionally pops up:
npm ERR! code ENOENT
npm ERR! path /tmp/TestSkip3421263667/001/node_modules/livebud
npm ERR! enoent ENOENT: Cannot cd into '/tmp/TestSkip3421263667/001/node_modules/livebud'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-05-15T08_05_47_433Z-debug-0.log
testdir_test.go:123: err: exit status 1
--- FAIL: TestSkip (2.92s)
FAIL
FAIL github.com/livebud/bud/internal/testdir 100.571s
I don't think we'll be using NPM after v0.3.0, so I don't think it's worth fixing these tests right now.
Hi, Firstly this project looks great. Really looking forward to working with it.
Getting the error...
bud/.app/controller/controller.go:133:15: too many return values
have (nil, error)
Looks the loadController() is missing a return error definination
func loadController() *controller.Controller { controllerController, err := controller.Load() if err != nil { return nil, err } return controllerController }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.