1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-05-29 06:30:52 +00:00

feat(go): check for go.work file to show Go module in prompt (#3968)

* check for go.work file to display go version

* add test to check for go.work file

* update docs to include go.work file

* chore(dprint): fmt & upgrade plugins (#3969)

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
This commit is contained in:
Arya Adarsha Gautam 2022-05-07 11:34:37 +05:30 committed by GitHub
parent a43628d06c
commit 9ebfce1e36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 10 deletions

View File

@ -556,6 +556,7 @@
"detect_files": [
"go.mod",
"go.sum",
"go.work",
"glide.yaml",
"Gopkg.yml",
"Gopkg.lock",
@ -2797,6 +2798,7 @@
"default": [
"go.mod",
"go.sum",
"go.work",
"glide.yaml",
"Gopkg.yml",
"Gopkg.lock",

View File

@ -1687,6 +1687,7 @@ By default the module will be shown if any of the following conditions are met:
- The current directory contains a `go.mod` file
- The current directory contains a `go.sum` file
- The current directory contains a `go.work` file
- The current directory contains a `glide.yaml` file
- The current directory contains a `Gopkg.yml` file
- The current directory contains a `Gopkg.lock` file
@ -1696,16 +1697,16 @@ By default the module will be shown if any of the following conditions are met:
### Options
| Option | Default | Description |
| ------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `symbol` | `"🐹 "` | A format string representing the symbol of Go. |
| `detect_extensions` | `["go"]` | Which extensions should trigger this module. |
| `detect_files` | `["go.mod", "go.sum", "glide.yaml", "Gopkg.yml", "Gopkg.lock", ".go-version"]` | Which filenames should trigger this module. |
| `detect_folders` | `["Godeps"]` | Which folders should trigger this module. |
| `style` | `"bold cyan"` | The style for the module. |
| `disabled` | `false` | Disables the `golang` module. |
| Option | Default | Description |
| ------------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `symbol` | `"🐹 "` | A format string representing the symbol of Go. |
| `detect_extensions` | `["go"]` | Which extensions should trigger this module. |
| `detect_files` | `["go.mod", "go.sum", "go.work", "glide.yaml", "Gopkg.yml", "Gopkg.lock", ".go-version"]` | Which filenames should trigger this module. |
| `detect_folders` | `["Godeps"]` | Which folders should trigger this module. |
| `style` | `"bold cyan"` | The style for the module. |
| `disabled` | `false` | Disables the `golang` module. |
### Variables

View File

@ -26,6 +26,7 @@ impl<'a> Default for GoConfig<'a> {
detect_files: vec![
"go.mod",
"go.sum",
"go.work",
"glide.yaml",
"Gopkg.yml",
"Gopkg.lock",

View File

@ -129,6 +129,18 @@ mod tests {
dir.close()
}
#[test]
fn folder_with_go_work() -> io::Result<()> {
let dir = tempfile::tempdir()?;
File::create(dir.path().join("go.work"))?.sync_all()?;
let actual = ModuleRenderer::new("golang").path(dir.path()).collect();
let expected = Some(format!("via {}", Color::Cyan.bold().paint("🐹 v1.12.1 ")));
assert_eq!(expected, actual);
dir.close()
}
#[test]
fn folder_with_godeps() -> io::Result<()> {
let dir = tempfile::tempdir()?;