The generated spec would be json not yaml at this stage, not saying it can't be made to do yaml but currently it only generates json.
you can annotate your main package with:
//go:generate swagger generate spec -o swagger.json
then you can generate the spec with:
go generate when you are in folder of the main package. If your main package is not your project root but something like
$project_root/cmd/my-server then you can run
go generate ./cmd/my-server from the project root.