tobyhede / go-underscore Goto Github PK
View Code? Open in Web Editor NEWHelpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness.
License: Other
Helpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness.
License: Other
EachP 方法出现数据丢失,不稳定复现
Is this library under actively development now?
I am interested in developing and maintaining the library. But just realised that the last commit is 4 years ago.
There are two things which prevent this package from being go get
compatible and idiomatic. The first can be fixed with a pull request, but the second requires changing the repository name/location.
Go projects use a single directory for all files in a package, and this directory generally has the same name as the package name (so src
directories aren't used in Go projects).
However, project names that end in .go
are no longer recognized by the entire Go toolchain, which means that the project name should really be underscore
(or perhaps __
, not `underscore.go).
(I was going to submit a pull request, but then I realized that the respository name ended in .go
, which ideally should be fixed before moving the files out of the src
directory; doing this in the other order would result in an inconsistent intermediate state.)
Can you add the proper
go get "github.com..."
and
import "github.com..."
lines to the readme for go noobs like me.
I browsed your code and have some suggestions.
first, I think underscore need a more general function instead of specifying a function for a certain type,for instance in order to map string you need to specify a SMap function pointer.Your code was excellent,could be there any way to implement such general function? such like not returning []interface{},but receive a point of return value as argument,in order to reflect the result.
second, in Each, I think sync.WaitGroup is more comlicated because it is implemented by lock,and why not do like
var done = make(chan struct{}{},m.Len()) //m is the map or slice
for i:= 0;i<s.Len();i++{
go func(){
donw <-
}()
}
for i:= 0;i<s.Len();i++{
done <-
}
I thins this dose the same work,but in more Go way.
third, function decleration is not constant,Each has argument name but Map does not which will make some confusion.
fourth chan argument should be more strict ,to spefigy read-only or write-only
reader need argument like job <- chan,which should only read from in the function body.
fifth , jobs in Each
should be bufferd capabible of len of workers number,
so that workers will not block on read or write and will be more akin parallel
That's my thoughts,maybe it's wrong or not appropriate,hoping to discuss!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.