Hi and Thanks Peter for your reply!  I have compiled this on my mac, and am 
running it on a linux system.  I compile it like this:

GOOS=linux GOARCH=amd64 go build  -o binaries/linux64/mysqlrun mysqlrun.go

Then I copy that binary to the server I am running it on and if there is an 
error -- it spits out an error message containing the path and the line 
number.  I've notice this happens with any program. OK this is only an 
example to show the error message. If you've got a program:
package main

import (
        "fmt"
        "strconv"
)

func main() {
        var divByS string
        fmt.Println("What do you want to divide by?")
        fmt.Printf("Number: ")
        fmt.Scanln(&divByS)
        fmt.Println("Great, divide 100 by " + divByS)
        divBy, err := strconv.Atoi(divByS)
        if err != nil {
                fmt.Printf("OOOpps %v\n", err)
        }
        x := 100 / divBy
        fmt.Println(x)
}

yes I know it's easy to catch a divide by zero, but it's to show the 
error... When I run this:

What do you want to divide by?
Number: 0
Great, divide 100 by 0
panic: runtime error: integer divide by zero

goroutine 1 [running]:
main.main()
/Users/rich/go/test.go:18 +0x2cf

I don't want the highlighted part to print.

On Tuesday, October 16, 2018 at 2:35:17 PM UTC-4, Peter Bourgon wrote:
>
> Error messages don't include any contextual information by default. If 
> the path to a Go file is in there, it's because whatever created the 
> error message (or modified it at some point) put it there. Where is 
> that error created, and what touches it as it flows through the call 
> stack to the logging statement that prints it to the screen? Don't 
> forget to also check the logging package itself, which can sometimes 
> annotate with caller information. Trace that out, and you'll find your 
> answer. 
> On Tue, Oct 16, 2018 at 11:28 AM Rich <rma...@gmail.com <javascript:>> 
> wrote: 
> > 
> > I apologize if this has been asked before but I searched google and this 
> group and didn't find it.  How do you remove the path from the error 
> messages?  So I have a valid error: 
> > 
> > 2018/10/16 18:13:12 [error] in 
> main.checkMaster[/Users/rich/go/mysqlrun/mysqlrun.go:739] Error 1045: 
> Access denied for user 
> > 
> > How do I get rid of the part highlighted above? It's a valid error. The 
> user specified the wrong password so I want the error -- I just don't want 
> the path part as a part of that error.  This happens any time there is an 
> error in a script, it prints out information about the author that I don't 
> particularly want published. 
> > 
> > Thanks 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "golang-nuts" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to golang-nuts...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to