Melkeydev / go-blueprint

Go-blueprint allows users to spin up a quick Go project using a popular framework
https://docs.go-blueprint.dev/
MIT License
5.81k stars 333 forks source link

[bug] live reload fixed #283

Closed jexroid closed 3 months ago

jexroid commented 4 months ago

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Problem/Feature

air live reload will be working on both Unixbased and Windows machines

Description of Changes:

  1. UnixBased with bool type is added to Project type
  2. CheckOs() function is added for checking the UNIX-based operating system if it's not windows leaves the UnixBased to false by default
    func (p *Project) CheckOs() {
    if runtime.GOOS != "windows" {
        p.UnixBased = true
    }
    }
  3. CheckOs() is executing in program.go:260
    // Define Operating system
    p.CheckOs()
  4. makefile.tmpl and air.toml.tmpl are modified

Checklist

Ujstor commented 4 months ago

@jexroid Nice PR! This solves the issue of manually configuring Air to get it working in Windows. Is there a way we can get the make watch command to work in Win? Check if Air is installed and offer an installation option. Is there a PowerShell syntax that will do the same as in Unix-based systems?

If not, we can use templating and just map make watch to air with a comment that Air can be installed with go install github.com/air-verse/air@latest

jexroid commented 4 months ago

thanks @Ujstor I think im able to write a PowerShell for that which checks if air command return system error or not found. and return error statement that tell the user to install it your self or do the instructions for installing it using GO get

jexroid commented 4 months ago

these failing tests are because of this:

{{if and (ne .DBDriver "none") (ne .DBDriver "sqlite")}}
# Integrations Tests for the application
itest:
    @echo "Running integration tests..."
    @go test ./internal/database -v
{{end}}

and the CI is testing for itest which will never exist in a project with no database or with sqlite is there anything else needed @Ujstor

Ujstor commented 3 months ago

I am a little bit busy...I will try to check the PR this weekend

jexroid commented 3 months ago

alright, as we discussed the purpose of this PR is to generate a binary version of the go project based on the user OS which is configured in Makefile and run the file in .air.toml which solve the hot reloading in windows machines but there will be no Air auto installation on windows but its behave like before for Unix base machines.

jexroid commented 3 months ago

seems like the Makefile:56: *** missing separator. Stop. occurs when you use spaces instead of tabs. I realized and fixed that while using Windows but couldn't test it on UNIX machines. the problems have been addressed and fixed.