sicoyle / txstcs

master repo for version control, applied throughout my college career.
1 stars 0 forks source link

parameterize loop iterations via os.Args #1

Open coip opened 5 years ago

coip commented 5 years ago

https://github.com/sicoyle/txstcs/blob/7857e21f4ce9268784813ea84eecc3349122fefc/projectEuler/Problem_001.go#L11

one approach might be: sed -i 's/1000/os.Args[len(os.Args)-1]/' Problem_001.go should do the trick, though you will also need to add "os" to your imports.

*for multi-ref imports, use the format:

import (
    "fmt"
    "os"
)
coip commented 5 years ago

could also use "pkg/flag", which would bake-in default values. for the os.Args approach you'll have to handle the NaN-err/default-val cases.