chore(go): print algo-stamps without errors
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b1278f431b
commit
ffc8b90e98
@ -4,7 +4,6 @@
|
||||
package algo
|
||||
|
||||
import (
|
||||
"log"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@ -16,9 +15,7 @@ type Values []float64
|
||||
func DoRandomSearch(wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
|
||||
if err := printRandomSearch("starting..."); err != nil {
|
||||
log.Printf("randomSearch: error printing RandomSearch to stderr: %q", err)
|
||||
}
|
||||
printRandomSearch("starting...")
|
||||
}
|
||||
|
||||
// DoStochasticHillClimbing performs a search using the 'Stochastic Hill
|
||||
@ -26,7 +23,5 @@ func DoRandomSearch(wg *sync.WaitGroup) {
|
||||
func DoStochasticHillClimbing(wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
|
||||
if err := printSHC("starting..."); err != nil {
|
||||
log.Printf("shc: error printing SHC to stderr: %q", err)
|
||||
}
|
||||
printSHC("starting...")
|
||||
}
|
||||
|
@ -20,10 +20,15 @@ func fmtRandomSearchOut(input string) string {
|
||||
return getRandomSearchLogPrefix() + " " + input
|
||||
}
|
||||
|
||||
func printRandomSearch(input string) error {
|
||||
_, err := fmt.Fprintln(os.Stderr, fmtRandomSearchOut(input))
|
||||
|
||||
return err
|
||||
func printRandomSearch(input string) {
|
||||
if _, err := fmt.Fprintln(os.Stderr, fmtRandomSearchOut(input)); err != nil {
|
||||
fmt.Fprintf(
|
||||
os.Stdout,
|
||||
getRandomSearchLogPrefix(),
|
||||
"error while printing to stderr: %q\n * original message was: %q",
|
||||
err, input,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func genValsRandomSearch(dimens uint, vals []float64, uniform *distuv.Uniform) {
|
||||
|
@ -15,7 +15,5 @@ func TestFmtRandomSearchOut(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrintRandomSearch(t *testing.T) {
|
||||
if err := printRandomSearch("whatever"); err != nil {
|
||||
t.Errorf("error while printing to stderr: %q", err)
|
||||
}
|
||||
printRandomSearch("whatever")
|
||||
}
|
||||
|
@ -16,8 +16,13 @@ func fmtSHCOut(input string) string {
|
||||
return getSHCLogPrefix() + " " + input
|
||||
}
|
||||
|
||||
func printSHC(input string) error {
|
||||
_, err := fmt.Fprintln(os.Stderr, fmtSHCOut(input))
|
||||
|
||||
return err
|
||||
func printSHC(input string) {
|
||||
if _, err := fmt.Fprintln(os.Stderr, fmtSHCOut(input)); err != nil {
|
||||
fmt.Fprintf(
|
||||
os.Stdout,
|
||||
getSHCLogPrefix(),
|
||||
"error while printing to stderr: %q\n * original message was: %q",
|
||||
err, input,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,5 @@ func TestFmtSHCOut(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrintSHC(t *testing.T) {
|
||||
if err := printSHC("whatever"); err != nil {
|
||||
t.Errorf("error while printing to stderr: %q", err)
|
||||
}
|
||||
printSHC("whatever")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user