[go-nuts] Re: Convert string to time.Duration

2022-04-03 Thread Amnon
Use time.ParseDuration() https://go.dev/play/p/SWUHBiSpflh On Sunday, 3 April 2022 at 23:48:54 UTC+1 vika...@gmail.com wrote: > I am looking to convert a *string* (say 4) to type *time.Duration*. > > I've looked around but could not find a way to do so. > > // https://go.dev/play/p/EUuDAY-Qx8N >

Re: [go-nuts] build unoptimized std lib for debugging

2022-04-03 Thread Ian Lance Taylor
On Sun, Apr 3, 2022 at 6:21 PM arthurwil...@gmail.com wrote: > > I'm trying to build an unoptimized version of the standard library for > debugging. You can just use go build -gcflags=all="-N -l" Ian -- You received this message because you are subscribed to the Google Groups "golang-nu

Re: [go-nuts] Re: First time contribution, unsure whether I need to open an issue or direct CL

2022-04-03 Thread Ian Lance Taylor
On Sun, Apr 3, 2022 at 3:07 PM Ramil M wrote: > > I am sorry, I may have not made myself clear earlier. This code is valid and > actually works fine for me. > I was just thinking that this particular example is very specific, where you > manipulate with bash, so that it forwards stdout to stderr

[go-nuts] build unoptimized std lib for debugging

2022-04-03 Thread arthurwil...@gmail.com
I'm trying to build an unoptimized version of the standard library for debugging. I tried using GO_GCFLAGS='-N -l' but dlv is telling me the code is optimized. This is what I did (Notice the "Warning debugging optimized function" coming from delve) /Volumes/git/goroot/src (master)$ git log --o

Re: [go-nuts] Tacit Golang?

2022-04-03 Thread Sam Hughes
You’re not far, but a couple corrections: 1. While a decent, native “compose” function would skip straight to point B, and as such would also accomplish point A, even with generics this is cumbersome. 2. Point A describes implementation of an infix pipe-operator, something implemented by nature o

[go-nuts] Re: Convert string to time.Duration

2022-04-03 Thread peterGo
func addHours(t time.Time, hours string) (time.Time, error) { i, err := strconv.ParseInt(hours, 10, 64) if err != nil { return time.Time{}, err } return t.Add(time.Hour * time.Duration(i)), nil } https://go.dev/play/p/jjLO54tbJn4 Peter On Sunday, April 3, 2022 at 6:48:54

[go-nuts] Convert string to time.Duration

2022-04-03 Thread vika...@gmail.com
I am looking to convert a *string* (say 4) to type *time.Duration*. I've looked around but could not find a way to do so. // https://go.dev/play/p/EUuDAY-Qx8N package main import ( "fmt" "time" ) func main() { // var addHours string = 4 fmt.Println(time.Now().Local()) timeAd

[go-nuts] Re: First time contribution, unsure whether I need to open an issue or direct CL

2022-04-03 Thread Ramil M
I am sorry, I may have not made myself clear earlier. This code is valid and actually works fine for me. I was just thinking that this particular example is very specific, where you manipulate with bash, so that it forwards stdout to stderr in it's second command(echo 1>&2 stderr). So in this c

[go-nuts] Re: First time contribution, unsure whether I need to open an issue or direct CL

2022-04-03 Thread Brian Candler
On Sunday, 3 April 2022 at 16:49:30 UTC+1 mirha...@gmail.com wrote: > CombinedOutput example listed above will always print only stdout, but not > combined stdout and stderr as intended to be shown in the example. Works for me (macOS 10.12, go 1.18) If this doesn't work for you, it could be th

Re: [go-nuts] [gollvm] enable GC in gollvm

2022-04-03 Thread Ian Lance Taylor
[ +thanm, cherryyz ] On Sun, Apr 3, 2022 at 8:49 AM Lanzhiguan Huang wrote: > > Hello, > By investigating the source code of gollvm and attempting to fix some bugs > in GoStatepoints.cpp, I have some questions about the current GC > implementation: > 1. Can an object pointer live in a callee-

Re: [go-nuts] First time contribution, unsure whether I need to open an issue or direct CL

2022-04-03 Thread Ian Lance Taylor
On Sun, Apr 3, 2022 at 8:49 AM Ramil M wrote: > > I want to make some example improvement suggestion in os/exec package. > However I am not sure if I need to submit code change through Gerrit or post > a new issue on GitHub first? Could you please advise? It is not necessary to open an issue i

[go-nuts] First time contribution, unsure whether I need to open an issue or direct CL

2022-04-03 Thread Ramil M
Hi everyone, I want to make some example improvement suggestion in os/exec package. However I am not sure if I need to submit code change through Gerrit or post a new issue on GitHub first? Could you please advise? CombinedOutput Example

[go-nuts] [gollvm] enable GC in gollvm

2022-04-03 Thread Lanzhiguan Huang
Hello, By investigating the source code of gollvm and attempting to fix some bugs in GoStatepoints.cpp, I have some questions about the current GC implementation: 1. Can an object pointer live in a callee-saved register and live through a call, recorded in the corresponding stackmap? Since go

Re: [go-nuts] Investigating suspected memory leak based on StackInUse or HeapSys stats

2022-04-03 Thread Shlomi Amit
So, I've configured pprof over http and downloaded the goroutines stack trace, apparently I did have an unintended endless recursion (1 additional function call every 5s) and I've fixed the issue. stackInUse is now normal. If I understand correctly, now it also makes sense why stackInUse didn't inc

Re: [go-nuts] Why doesn't Go use atomic.LoadInt32() in sync.Mutex.lockSlow()?

2022-04-03 Thread liweiforeveryoung
Thanks for your reply,Ian.I've always had a misunderstanding about atomic operation,I thought atomic operation is only used to protect the CPU instructions from being interrupted. I have watched some lectures about C++ memory order on youtube.As you mentioned,another function of atomic operat

Re: [go-nuts] Why doesn't Go use atomic.LoadInt32() in sync.Mutex.lockSlow()?

2022-04-03 Thread liweiforeveryoung
Thanks for your reply,eric.I've always focused on this situation,without atomic operator,If goroutine A set a variable v to 0 and goroutine B set the variable a to 1,anther goroutine C would probably get a unexpected value which is neither 0 nor 1 when its read operation of a is interrupted.S