Skip to content

Conversation

@pd93
Copy link
Member

@pd93 pd93 commented Apr 28, 2025

Closes #1346

Adds the following random functions:

  • uuid
  • randInt
  • randIntN
  • randFloat
version: '3'

tasks:
  default:
    cmds:
      - echo "{{uuid}}"
      - echo "{{randInt}}"
      - echo "{{randIntN 10}}"
      - echo "{{randFloat}}"
task: [default] echo "054f74a5-19e3-47c0-a80e-50c8cac3e81b"
054f74a5-19e3-47c0-a80e-50c8cac3e81b
task: [default] echo "5927110203314446318"
5927110203314446318
task: [default] echo "7"
7
task: [default] echo "0.23945671"
0.23945671

"uuid": uuid.New,
"randInt": rand.Int,
"randIntN": rand.IntN,
"randFloat": rand.Float32,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a random float really useful here? Integer might be enough. No strong opinion, just asking...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not, I really only added them as they come for free with the std lib. I can imagine that a number between 0 and 1 is sometimes useful in stats/probability. However, you're probably not going to be doing anything like that inside the Taskfile itself. I will remove for now and if someone gives a valid case for it in the future we can revisit pretty easily.

@pd93 pd93 enabled auto-merge (squash) May 1, 2025 17:56
@pd93 pd93 merged commit 6528b36 into main May 1, 2025
14 checks passed
@pd93 pd93 deleted the 1346-random-functions branch May 1, 2025 17:58
pd93 added a commit that referenced this pull request May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

define random strings

3 participants