[go-nuts] Looking to maximize performance when using ethereum-ethash

2022-09-23 Thread ramki...@hotmail.com
I tried using bench on AWS servers (the most expensive Compute and Memory 
Optimized ones) 
on https://github.com/hackmod/ethereum-ethash/blob/master/ethash_test.go#L88 
but for each server (from 2 cores all the way to 64 cores) they all give 
similar numbers 9-12 seconds.

cpu: Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz
BenchmarkProcessShare-32   21015472592 ns/op  101924 
B/op 636 allocs/op
BenchmarkProcessShare-32   21024122370 ns/op  102456 
B/op 637 allocs/op
BenchmarkProcessShare-32   11036610777 ns/op  108408 
B/op 640 allocs/op
BenchmarkProcessShare-32   11032957803 ns/op  108904 
B/op 642 allocs/op
BenchmarkProcessShare-32   11004457663 ns/op  107336 
B/op 636 allocs/op
PASS
ok   9.646s

Is there a way to optimize this or is there a better package for this that 
I'm not aware of?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2ef91e6d-11ca-47ad-9f74-2c0403a4b479n%40googlegroups.com.


[go-nuts] Re: Go Get Issues

2022-09-23 Thread Rich
Sorry the last line was messed up.

The error I get is:
 github.com/stretchr/testify/require: 
repository.web.mycompany.com/st_nsres@ v0.2.0: unrecognized import path 
"repository.web.mycompany.com/st_nsres":   https fetch: Get 
"https://repository.web.mycompany.com/st_nsres?go-get=1": 
 Unable to connect

It keeps trying to connect via https -- IT's SSH
Again I have ~/.gitconfig configured:

[url "ssh://g...@internal.repository.web.mycompany.com:7999/ 
"]
 insteadOf = https://repository.web.mycompany.com/

And GOPRIVATE set to repository.web.mycompany.com
On Friday, September 23, 2022 at 4:59:44 PM UTC-4 Rich wrote:

> I have been having a really hard time with Go Get It just isn't working. 
> We have a private Repositiory, that repository requires us to use SSH. 
> There is no option for using https.
>
> So, I've configured my git config "~/.gitconfig' 
>
> ```
> [url "ssh://g...@internal.repository.web.mycompany.com:7999/ 
> "]
>  insteadOf = https://repository.web.mycompany.com/
> ```
> I have GOPRIVATE set
> ```
> export GOPRIVATE="repository.web.mycompany.com"
> ```
> Then when I use go get:
> ```
> repository.web.mycompany.com
> ```
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1582c370-7bc9-4674-bf49-4271fdcd7816n%40googlegroups.com.


Re: [go-nuts] Using golang variable in bash script Command

2022-09-23 Thread Rich
I do a lot of 'scripting' like things with Go - I found that using 
github.com/bitfield/script makes it a TON easier to run commands and you 
can pipe a command into another command, etc. Worth checking it out. 

On Tuesday, September 20, 2022 at 9:13:03 AM UTC-4 drro...@gmail.com wrote:

> I've done this for Linux and windows, as I regularly use both.  But I used 
> a different strategy.  I used the os functions to retrieve a slice of 
> strings that I can then filter and sort as I desire.  And I use the command 
> line to get the target string.
>
> github.com/drrob1/src/dsrt
> also in that repo is ds and rex that do this. dsrtr and dsrtre search all 
> subdirectories down from the current dir for what you describe.
> And I also sort the returned list by time w/ the most recent first.
> --rob solomon
>
> On Monday, September 19, 2022 at 12:08:24 PM UTC-4 princ...@gmail.com 
> wrote:
>
>> Thank you for the response.
>>
>> On Mon, Sep 19, 2022 at 8:26 PM Tamás Gulácsi  wrote:
>>
>>> No, please, no!
>>>
>>> Do NOT use bash with string interpolation if possible!
>>> Call find directly:
>>> *cmd, err := exec.Command("find", ".", "-name", search)*
>>> princ...@gmail.com a következőt írta (2022. szeptember 19., hétfő, 
>>> 12:04:32 UTC+2):
>>>
 then we don't need to add these commands 



 *scanner := bufio.NewScanner(os.Stdin)fmt.Println("Enter the substring 
 name")scanner.Scan()search:=scanner.Text()*
  right???

 we only need to keep this one
  *cmd, err := exec.Command("bash", "-c", fmt.Sprintf("find . -name 
 %s", search))*

 On Monday, September 19, 2022 at 3:31:12 PM UTC+5:30 Jan Mercl wrote:

> On Mon, Sep 19, 2022 at 11:50 AM PK  wrote:
>
> > search:=scanner.Text()
> > cmd1,err:=exec.Command("bash", "-c", "find . -name '*$search*'")
>
> Try something like this, not tested:
>
> cmd, err := exec.Command("bash", "-c", fmt.Sprintf("find . 
> -name %s", search))
>
> -- 
>>> 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.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/fb987200-6678-443f-a0ab-884b5f77c324n%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e0e1c0b2-c976-48ca-a0fa-0be3d81397ean%40googlegroups.com.


[go-nuts] Go Get Issues

2022-09-23 Thread Rich
I have been having a really hard time with Go Get It just isn't working. We 
have a private Repositiory, that repository requires us to use SSH. There 
is no option for using https.

So, I've configured my git config "~/.gitconfig' 

```
[url "ssh://g...@internal.repository.web.mycompany.com:7999/"]
 insteadOf = https://repository.web.mycompany.com/
```
I have GOPRIVATE set
```
export GOPRIVATE="repository.web.mycompany.com"
```
Then when I use go get:
```
repository.web.mycompany.com
```

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d4e71bf9-f56d-46ac-803a-19f151ea44a4n%40googlegroups.com.


[go-nuts] how to organise code with channels and error handling?

2022-09-23 Thread Jochen Voss
Dear all,

I am writing a program which processes data in stages.  To structure the 
code cleanly, I would like implement each stage as an individual function 
and use channels to pass data between stages.

My questions:
- How to structure the code?  Is my approach described below reasonable?
- How to deal with errors?

Here is a sketch of I currently have (runnable version 
at https://go.dev/play/p/7Rrq-OLARl_R ):

func getInputs() <-chan t1 {
c := make(chan t1)
go func() {
for ... {
...
c <- x
}
close(c)
}()
return c
}

func process(in <-chan t1) <-chan t2 {
c := make(chan t2)
go func() {
for i := range in {
x, err := ...
_ = err // what to do with the error?
c <- x
}
close(c)
}()
return c
}

func main() {
c1 := getInputs()
c2 := process(c1)
summarise(c2)
}

There are some things I like about this approach:

   - the main function looks nice and tidy
   - the stages of work are cleanly separated

But there are also things I don't like:

   - I can't see an obvious way to handle errors in the stages.  In my case 
   the first stage is locating input files on the file system, and there may 
   be read errors etc.  The second stage processes the files, and files may 
   have invalid contents.
   - The code for the individual stages looks a bit strange with the double 
   indentation from the outer func(){} and the go func() {}().

So my questions are:

   - What would be a good way to incorporate error handling into my code?  
   I assume this will require one or more additional channels, just for 
   errors.  Or is there a better way?
   - Is there a better way to structure my code?

Many thanks,
Jochen

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/cd4e086c-4f1c-4a48-9162-c46ab45df66fn%40googlegroups.com.


Re: [go-nuts] understanding interface conversions

2022-09-23 Thread Rory Campbell-Lange
On 23/09/22, Ian Davis (m...@iandavis.com) wrote:
> On Thu, 22 Sep 2022, at 11:27 PM, Rory Campbell-Lange wrote:
> 
> I just wanted to respond to this part:
> 
> > I suppose my question is (and forgive me if this is a terrifically naive),
> > how can one negotiate the go landscape of commonly used modules to
> > re-utilise, where possible, a more commonly named interface implementing
> > "Speak()" or convertible to provide "Speak()"?
> 
> Generally, when writing Go, the consumer of the object defines the interface 
> it requires. So rather than you looking for interfaces that might exist in 
> the wild, it's better to focus on your application and its needs. If you have 
> a component that uses the Speak method on objects then define that as an 
> interface that your component can accept. Any other user of your component 
> can see that interface is needed and provide a suitable object that 
> implements it or create a shim to adapt one.

I find this is a very interesting perspective. It certainly seems easier to 
think about defining interfaces for one's own types than trying to select from 
n possible interface "contracts" on offer.

I assume, though, that it makes sense to support commonly occuring method sets 
a.k.a. interfaces to improve reusability and readability of one's own modules? 
If so, how does one go about getting to know what those commonly occuring 
interfaces are?

Thanks
Rory

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/Yy2hbfOrXGrkZN7f%40campbell-lange.net.


Re: [go-nuts] understanding interface conversions

2022-09-23 Thread Rory Campbell-Lange
On 22/09/22, burak serdar (bser...@computer.org) wrote:
> On Thu, Sep 22, 2022 at 4:27 PM Rory Campbell-Lange 
> wrote:
> 
> > ...I'm interested to learn how people negotiate interface
> > interchangeability in their programmes as my query above showed a basic
> > misunderstanding of how that operates and how to approach the topic in
> > general.
> >
...
> > ...Jordan Orelli uses the example of "...the Animal type will be an
> > interface, and we’ll define an Animal as being anything that can speak". He
> > writes:
> 
> I think one of the problems in this particular example is that it is for
> some reason easy for people to accept Animal type to be something that can
> speak. I can see that it is simply an example to show the mechanics of
> interfaces, but it also sets the expectation that the interface name means
> more than what it actually is: in Go, an interface is simply a method set.
> This is a difficult concept for people coming from other languages. So you
> can have:
> 
> if speaker, yes:=someInterfaceValue.(interface{Speak() string}); yes {
> spearer.Speak()
> }
> 
> without having a named interface at all.
> 
> That is one of the properties of duck-typing I enjoy, especially after
> working with Java for many years. In Java, an interface is a contract. In
> Go, an interface is just a method set, which can be used as a contract.

Thank you for thoughtful comment about interface names being simply labels on 
method sets.

In this case the compiler did not enforce the contract. (As I noted in my 
original email, converting an fs.File to an io.ReadSeeker for an underlying zip 
file failed, but only at runtime).

If interfaces provide contracts, though, it would be great if type "interface 
satisfaction"[1] could be more thoroughly checked at compile time.

Regards,
Rory

[1] The description "Interface Satisfaction" is used in section 7.3 of "The Go 
Programming Language"


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/Yy2f9SwcoFVPDCbX%40campbell-lange.net.


Re: [go-nuts] Re: private go documentation server similar to https://pkg.go.dev

2022-09-23 Thread 'Sebastien Binet' via golang-nuts
On Fri Sep 23, 2022 at 07:32 CET, brainman wrote:
> Thank you Sebastian,
>
> That might actually work for me. I will play with it to see if it suits
> us.
> I still wish I can just use https://pkg.go.dev , but we cannot have
> everything.
>
> I also want to thank you for writing http://github.com/go-daq/canbus . I
> was using your package to control some equipment from Raspberry PI.

the project I developed it for is now long gone, but I am glad this
could be of some help.

-s

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CN3OW2OVS1JU.2OMHR47MDP3OU%40clrinfopc42.


Re: [go-nuts] Very curious, why is "3:04 PM" named Kitchen in the time package?

2022-09-23 Thread 'Axel Wagner' via golang-nuts
It's not the time, it's the time format. Formatting in the time package
happens according to how the reference time is displayed:

Layout = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical
order.

1234567. With PM chosen to distinguish between a 3 (meaning 12h clock hour)
and 15 (meaning 24h clock hour).

And yes, Tobias is correct that "Kitchen" refers to "what the clock on your
microwave or oven may show" - as long as you live in a 12h clock country,
at least. So "3:04 PM".

On Fri, Sep 23, 2022 at 11:22 AM fliter  wrote:

> Is it because it is time to go to the kitchen to cook? It seems that 3:04
> PM is too early
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/92bd089d-ad71-4f1f-a3d3-552edfc15a5an%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfEHQEadRir%3DBDfYsjQEXepttCibDEacnsq%3D0%2BAot1CXhA%40mail.gmail.com.


Re: [go-nuts] Very curious, why is "3:04 PM" named Kitchen in the time package?

2022-09-23 Thread Tobias Klausmann
Hi! 

On Fri, 23 Sep 2022, fliter wrote:
> Is it because it is time to go to the kitchen to cook? It seems that 3:04 
> PM is too early

My best guess: it's the most common way kitchen timers that also are
clocks display the time. It's not the specific time that is
"kitchen"-likem, but rather the format. Ditto for the clocks you often
find on ovens and microwaves: their displays usually are in the format
(in the US, Europeans usually have 24h time).

Best,
Tobias
-- 
Sent from aboard the Culture ship
GCU Credibility Problem

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/Yy18hswoOg2Blynm%40skade.schwarzvogel.de.


[go-nuts] Very curious, why is "3:04 PM" named Kitchen in the time package?

2022-09-23 Thread fliter
Is it because it is time to go to the kitchen to cook? It seems that 3:04 
PM is too early

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/92bd089d-ad71-4f1f-a3d3-552edfc15a5an%40googlegroups.com.


[go-nuts] Re: Question on 'src/internal/singleflight': The return result of the ForgetUnshared method seems to be inaccurate

2022-09-23 Thread Brian Candler
On Friday, 23 September 2022 at 03:23:29 UTC+1 atomic wrote:

> Thank you so much, so happy, you are amazing.
> You answered a question that has been bothering me for days


Thank you for providing a carefully isolated and reproducible problem.  It 
was a fun challenge!

And thanks to Cuong for creating the full patch and a proper test case. 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4aba5a50-7ce2-430e-8917-28a66ba4e6b2n%40googlegroups.com.


Re: [go-nuts] Re: private go documentation server similar to https://pkg.go.dev

2022-09-23 Thread brainman
I did not have GO111MODULE set.

a@spot:~$ env | grep GO
GOROOT_BOOTSTRAP=/home/a/go1.18.5
GOROOT=/home/a/go
GOPATH=/home/a
a@spot:~$

and I use current Go tip.

godoc only shows "Third party" section if I am inside of any go module 
directory, but not in /tmp .

a@spot:~$ cd /tmp
a@spot:/tmp$ godoc -http :8080
using module mode; GOMOD=/dev/null
^C
a@spot:/tmp$ cd ~/src/golang.org/x/sys/
a@spot:~/src/golang.org/x/sys$ godoc -http :8080
using module mode; GOMOD=/home/a/src/golang.org/x/sys/go.mod
go: no module dependencies to download
^C
a@spot:~/src/golang.org/x/sys$

Note how GOMOD setting changes in godoc output as I change my directories.

If I use GO111MODULE environment variable

a@spot:~$ cd /tmp
a@spot:/tmp$ GO111MODULE=off godoc -http :8080
using GOPATH mode
^C
a@spot:/tmp$ cd ~/src/golang.org/x/sys/
a@spot:~/src/golang.org/x/sys$ GO111MODULE=off godoc -http :8080
using GOPATH mode
^C
a@spot:~/src/golang.org/x/sys$

then godoc displays "using GOPATH mode" message, and displays all packages 
I have in my GOPATH on one large single page.

This is not useful in my scenario, because we have many independent teams 
working on many independent Go repos. I don't see how it would be possible 
for me to automatically download and keep up-to-date then all into single 
GOPATH. And it would be overwhelming to see all our packages on one single 
page. And godoc does not displays package versions.

But thanks for trying.

Alex
On Monday, 12 September 2022 at 18:31:11 UTC+10 Jan Mercl wrote:

> On Mon, Sep 12, 2022 at 10:01 AM brainman  wrote:
>
> > I managed to run godoc.
> >
> > But godoc only displays standard library packages.
> >
> > Is it possible to configure godoc so it displays packages stored in 
> private github repos ?
>
> I use it with no configuration, '$ GO111MODULE=off godoc -http :6060
> &` in particular, and it also shows all packages in $GOPATH. Maybe
> setting GOPATH is the configuration you need.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/637adbbb-2649-4815-94ae-3d989f0512adn%40googlegroups.com.