github.com/hairyhenderson/gomplate/v4@v4.0.0-pre-2.0.20240520121557-362f058f0c93/docs/content/functions/semver.md (about) 1 --- 2 title: semver functions 3 menu: 4 main: 5 parent: functions 6 --- 7 8 These functions allow user you to parse a [semantic version](http://semver.org/) string or test it with constraint. 9 10 It's implemented with the https://github.com/Masterminds/semver library. 11 12 ## `semver.Semver`_(unreleased)_ 13 **Unreleased:** _This function is in development, and not yet available in released builds of gomplate._ 14 15 Returns a semantic version struct holding the `input` version string. 16 17 The returned struct are defined at: [`semver.Version`](https://pkg.go.dev/github.com/Masterminds/semver/v3#Version). 18 19 ### Usage 20 21 ``` 22 semver.Semver input 23 ``` 24 ``` 25 input | semver.Semver 26 ``` 27 28 ### Arguments 29 30 | name | description | 31 |------|-------------| 32 | `input` | _(required)_ The input to parse | 33 34 ### Examples 35 36 ```console 37 $ gomplate -i '{{ semver.Semver "v1.1.1"}}' 38 1.1.1 39 ``` 40 ```console 41 $ gomplate -i '{{ (semver.Semver "v1.1.1").Major }}' 42 1 43 ``` 44 ```console 45 $ gomplate -i 'the pre release version is {{ ("v1.1.1" | semver.Semver).SetPrerelease "beta.1" }}' 46 the pre release version is 1.1.1-beta.1 47 ``` 48 49 ## `semver.CheckConstraint`_(unreleased)_ 50 **Unreleased:** _This function is in development, and not yet available in released builds of gomplate._ 51 52 Test whether the input version matchs the constraint. 53 54 Ref: https://github.com/Masterminds/semver#checking-version-constraints 55 56 ### Usage 57 58 ``` 59 semver.CheckConstraint constraint input 60 ``` 61 ``` 62 input | semver.CheckConstraint constraint 63 ``` 64 65 ### Arguments 66 67 | name | description | 68 |------|-------------| 69 | `constraint` | _(required)_ The constraints expression to test. | 70 | `input` | _(required)_ The input semantic version string to test. | 71 72 ### Examples 73 74 ```console 75 $ gomplate -i '{{ semver.CheckConstraint "> 1.0" "v1.1.1" }}' 76 true 77 ``` 78 ```console 79 $ gomplate -i '{{ semver.CheckConstraint "> 1.0, <1.1" "v1.1.1" }}' 80 false 81 ``` 82 ```console 83 $ gomplate -i '{{ "v1.1.1" | semver.CheckConstraint "> 1.0" }}' 84 true 85 ```