On Tue, Oct 16, 2018 at 11:57 AM, Rich <rma...@gmail.com> 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(&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.

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.

Reply via email to