Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In t = time.Now() expression t will change its value each time you print it #58

Closed
dengshuan opened this issue Dec 9, 2015 · 3 comments

Comments

@dengshuan
Copy link

When asign time.Now() to a variable, that variable is not fixed and changes every time you print it

t1 := time.Now()
t2 := time.Now()
t1 // one value
t1 // would print another value
t2.Sub(t1)
t2.Sub(t1) // different from previous evaluation

my gore version is 0.2.5 and go version is 1.5.2

@motemen
Copy link
Member

motemen commented Dec 11, 2015

Unfortunately this is an expected behavior of gore, which invokes go run on each REPL input. You cannot expect the same values to be printed if the code involves I/O.

I'd love to hear any idea to solve this problem, thanks.

@motemen motemen closed this as completed Dec 11, 2015
@HALtheWise
Copy link

To fix this, gore could substitute its own wrappers for certain standard library packages that store the output in a database and regurgitate it rather than executing again. This would also fix the counterintuitive behavior caused by typing multiple fmt.Println(...) calls in one repl shell. I'm not sure how to properly extend this behavior beyond the standard library, as detecting and recording the side-effects of unknown functions is hard.

@itchyny itchyny reopened this Feb 15, 2019
@itchyny
Copy link
Collaborator

itchyny commented Jan 20, 2020

This is a core issue of gore but closing as duplicate of #67.

@itchyny itchyny closed this as completed Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants