I run web projects like this, during development:
dotnet watch run
The project/browser reloads when I make a change. Awesome!
However, sometimes I will be shown this:
Unable to apply hot reload because of a rude edit.
Do you want to restart your app - Yes (y) / No (n) / Always (a) / Never (v)?
Is there something I can add to the commandline, so I force the Always (a) option?
Something like this:
dotnet watch run --AlwaysRestartOnRudeEdit
According to my google-fu/duckduck-fu, such an option does not exist - but I would like it confirmed. :)
Not yet. A feature like that has been merged into the .NET 6.0.2 update. Once released, it will be possible to force this behavior by setting an environment variable named DOTNET_WATCH_RESTART_ON_RUDE_EDIT to true.
Source: aspnetcore issue #37190
Until then, user eknkc posted a possible workaround (Unix):
#!/usr/bin/env expect -f
set timeout -1
spawn dotnet watch run
expect "Do you want to restart your app - Yes (y) / No (n) / Always (a) / Never (v)?\r"
send -- "a"
expect eof
Create an environment variable DOTNET_WATCH_RESTART_ON_RUDE_EDIT set to true. The run dotnet watch like normal.
Related
I'm having an issue with using custom substitutions in my cloudbuild.yaml.
substitutions:
_CUSTOM_SUBSTITUTION: this-is-a-path
availableSecrets:
secretManager:
- versionName: projects/$_CUSTOM_SUBSTITUTION/secrets/client_id/versions/1
env: CLIENT_ID
- versionName: projects/$_CUSTOM_SUBSTITUTION/secrets/client_secret/versions/1
env: CLIENT_SECRET
From what I can tell from trial and error, using something like $PROJECT_ID in the place of $_CUSTOM_SUBSTITUTION will run the build, but if I use a custom substitution like above, the trigger does not run a build at all when a commit is pushed.
I've also tested with various other base substitutions, like $BRANCH_NAME to the same effect. I'm getting the feeling that it's just not possible to do this in cloudbuild at the moment?
It ended up being a combination of need curly braces ${_CUSTOM_SUBSTITUTION} and some syntax fixing in the cloudbuild.yaml. I didn't have enough experience with cloudbuild to find that.
The offending part was something this:
AUTH_TOKEN=$$(cat /workspace/token.txt). Originally I had just 1 $ there, which was also working code pulled from another project.
For anyone running into this in the future, using gloud builds submit can let you run it directly for troubleshooting.
I am a newbie in go and go-swagger. I am following steps in Simple Server tutorial in goswagger.io.
I am using Ubuntu 18.04, swagger v0.25.0 and go 1.15.6.
Following the same steps, there are a few differences of the files generated. For instance, goswagger.io's has find_todos_okbody.go and get_okbody.go in models but mine does not. Why is that so?
Link to screenshot of my generated files vs
Link to screenshot of generated files by swagger.io
Starting the server as written in the tutorial go install ./cmd/todo-list-server/ gives me the following error. Can anyone please help with this?
# my_folder/swagger-todo-list/restapi
restapi/configure_todo_list.go:41:8: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
restapi/configure_todo_list.go:42:6: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
The first step in goswagger.io todo-list is swagger init spec .... Which directory should I run this command in? I ran it in a newly created folder in my home directory. However, from the page, it shows the path to be ~/go/src/github.com/go-swagger/go-swagger/examples/tutorials/todo-list. I am not sure whether I should use go get ..., git clone ... or create those folders. Can someone advise me?
Thanks.
This is likely the documentation lagging behind the version of the code that you are running. As long as it compiles, the specific files the tool generates isn't so crucial.
This is a compilation error. When you do go install foo it will try to build the foo package as an executable and then move that to your GOPATH/bin directory. It seems that the generated code in restapi/configure_todo_list.go isn't correct for the operations code generated.
All you need to run this tutorial yourself is an empty directory and the swagger tool (not its source code). You run the commands from the root of this empty project. In order not to run into GOPATH problems I would initialise a module with go mod init todo-list-example before doing anything else.
Note that while the todo-list example code exists inside the go-swagger source, it's there just for documenting example usage and output.
What I would advice for #2 is to make sure you're using a properly released version of go-swagger, rather than installing from the latest commit (which happens when you just do a go get), as I have found that to be occasionally unstable.
Next, re-generate the entire server, but make sure you also regenerate restapi/configure_todo_list.go by passing --regenerate-configureapi to your swagger generate call. This file isn't always refreshed because you're meant to modify it to configure your app, and if you changed versions of the tool it may be different and incompatible.
If after that you still get the compilation error, it may be worth submitting a bug report at https://github.com/go-swagger/go-swagger/issues.
Thanks #EzequielMuns. The errors in #2 went away after I ran go get - u -f ./... as stated in
...
For this generation to compile you need to have some packages in your GOPATH:
* github.com/go-openapi/runtime
* github.com/jessevdk/go-flags
You can get these now with: go get -u -f ./...
I think it's an error of swagger code generation. You can do as folloing to fix this:
delete file configure_todo_list.go;
regenerate code.
# swagger generate server -A todo-list -f ./swagger.yml
Then, you can run command go install ./cmd/todo-list-server/, it will succeed.
I just started using Git with the TortoiseGit 2.8.0.0 client on Windows 10 and was trying to set up some client-side hooks. I would like to set them up in a way so that they are automatically set when I or my colleagues clone the repo so I checked "Run for this repository".
I noticed that the Start-commit Hook isn't being executed in that case. Pre-commit and Post-commit seem to work as expected.
If I provide the working tree path and don't check "Run for this repository" all scripts also run as expected.
For testing I just set the same script for all 3 hooks to see if they are working.
My .tgitconfig looks like this:
[hook "startcommit"]
cmdline = %root%\\ARM\\start_commit.bat
wait = true
show = false
[hook "postcommit"]
cmdline = %root%\\ARM\\start_commit.bat
wait = true
show = false
[hook "precommit"]
cmdline = %root%\\ARM\\start_commit.bat
wait = true
show = false
Can anyone explain this behaviour and how to fix it? am I missing something here?
That's a reproducible bug which will be fixed with the next (preview) release (version >= 2.8.4 are fixed).
There is no workaround, but to define it with a repository path, too.
I cannot find a suitable solution for my needs with running a Go project inside a Sublime Text 3 and seeing it's output in real-time.
If I try a build system from:
GoSublime - I can use run, it even runs and stops, but there is no output, which I need. It appears only when I cancel build - it's too late.
Official Golang Build from Go developers - I can build the project, and that's it. It allows to run 1 file (current) only, but I need the whole project.
I've tried to use flags for run command and to add *.go, but then I get *.go: no such file or directory
How do I see the output in real-time in one of these solutions? I've tried to create my own build system with shell_cmd = go run *.go, but stopping the process with Cancel build is not working then. Maybe you can explain how do I stop a running Go program? My mybuild.sublime-build is similar to this:
{
"env": {
"GOROOT": "/path/gosrc/go",
"GOPATH": "/path/godev"
},
"path": "$PATH:/path/gosrc/go/bin",
"working_dir": "/path/godev/src/github.com/user/program",
"cmd": "go run *.go",
"shell": true
}
..I can run Build and see the needed output, but how do I then stop a running process?
P.S. Program is not just executing and exiting - it's a service, so I should see the output when the needed actions happens.
I personally use GoSublime and go build . followed by running the app by name as a second command. Obviously this sucks in a lot of ways, but it kinda sorta works most of the time. It provides a nice fast way to check for compile errors, which is most of what I need.
Honestly, just running in a dedicated shell is nicer in every way.
AFAIK, there is no better Go build system available for Sublime Text (that isn't an endorsement, it sucks, just less than most).
I found a tutorial where I was able to run Go files on build in Sublime Text 3 here: https://www.alexedwards.net/blog/streamline-your-sublime-text-and-go-workflow
If you use Build With: Go - Run you get outputs, but if you are running for example a net/http local host in Go you won't be able to run multiple programs and cancel build also does not work.
Here is an example of simple fmt.Println output in Sublime Text 3:
> Environment:
> GOPATH=C:/Users/Christiaan/go
> Directory: C:\Users\Christiaan\Documents\02_Personal\04_Learning\09_Go\01_test
> Command: C:\Users\Christiaan\go\go1.15rc1\bin\go.exe run -v C:\Users\Christiaan\Documents\02_Personal\04_Learning\09_Go\01_test\test2.go
> Output:
command-line-arguments
gas_pedal: 22314 brake_pedal: 0 steering_wheel: 12562
> Elapsed: 3.856s
> Result: Success
I have a simple project I am trying to work with.
doctype html
html(lang="en")
include ./inc/head.jade
body
include ./inc/various.jade
include ./inc/types.jade
include ./inc/of.jade
include ./inc/things.jade
using this commmand to watch
jade -w index.jade
I would expect any change to 'things.jade' would trigger a refresh to 'index.jade'. It does not. What am I missing? I don't want to call the watch command each time I need a refresh on index.jade.
Desired workflow:
save change in things.jade > triggers refresh to index.jade
Current problem:
save change in things.jade > switch to terminal > control+c to
kill the watch on index.jade > jade -w index.html
I have just seen your question now, I hope you got it fixed.
It seems you require 'liveReload' to watch for changes when you save a file then to reload your browser.
If you are using a task runner for example 'gulp' is would strongly recommend using 'gulp-connect' It runs a local web server using 'LiveReload'
Using this technique you will not have to call the watch command each time you need a refresh on index.jade