1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-24 21:57:41 +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": [ "detect_files": [
"go.mod", "go.mod",
"go.sum", "go.sum",
"go.work",
"glide.yaml", "glide.yaml",
"Gopkg.yml", "Gopkg.yml",
"Gopkg.lock", "Gopkg.lock",
@ -2797,6 +2798,7 @@
"default": [ "default": [
"go.mod", "go.mod",
"go.sum", "go.sum",
"go.work",
"glide.yaml", "glide.yaml",
"Gopkg.yml", "Gopkg.yml",
"Gopkg.lock", "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.mod` file
- The current directory contains a `go.sum` 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 `glide.yaml` file
- The current directory contains a `Gopkg.yml` file - The current directory contains a `Gopkg.yml` file
- The current directory contains a `Gopkg.lock` 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 ### Options
| Option | Default | Description | | Option | Default | Description |
| ------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------- | | ------------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. | | `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | | `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `symbol` | `"🐹 "` | A format string representing the symbol of Go. | | `symbol` | `"🐹 "` | A format string representing the symbol of Go. |
| `detect_extensions` | `["go"]` | Which extensions should trigger this module. | | `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_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. | | `detect_folders` | `["Godeps"]` | Which folders should trigger this module. |
| `style` | `"bold cyan"` | The style for the module. | | `style` | `"bold cyan"` | The style for the module. |
| `disabled` | `false` | Disables the `golang` module. | | `disabled` | `false` | Disables the `golang` module. |
### Variables ### Variables

View File

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

View File

@ -129,6 +129,18 @@ mod tests {
dir.close() 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] #[test]
fn folder_with_godeps() -> io::Result<()> { fn folder_with_godeps() -> io::Result<()> {
let dir = tempfile::tempdir()?; let dir = tempfile::tempdir()?;