Re: [go-nuts] Remove path from error messages

2018-10-17 Thread Richard Masci
That is what I was looking for!! Thanks!!

On Tue, Oct 16, 2018 at 4:16 PM Ian Lance Taylor  wrote:

> On Tue, Oct 16, 2018 at 11:57 AM, Rich  wrote:
> > 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()
> > 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.
>
> go build -gcflags=-trimpath=/Users/rich/go
>
> Ian
>

-- 
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.


Re: [go-nuts] Remove path from error messages

2018-10-16 Thread Ian Lance Taylor
On Tue, Oct 16, 2018 at 11:57 AM, Rich  wrote:
> 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()
> 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.

go build -gcflags=-trimpath=/Users/rich/go

Ian

-- 
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.


Re: [go-nuts] Remove path from error messages

2018-10-16 Thread Rich
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()
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 > 
> 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 . 
> > 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.


Re: [go-nuts] Remove path from error messages

2018-10-16 Thread Peter Bourgon
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  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+unsubscr...@googlegroups.com.
> 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.


[go-nuts] Remove path from error messages

2018-10-16 Thread Rich
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.