Re: [go-nuts] rebuild & reinstall pkg/tool/.../link

2019-10-09 Thread Jan Mercl
On Wed, Oct 9, 2019 at 12:10 PM Liam wrote: > > I have the current 1.12 release from a Linux distro, installed in /usr/lib/go. > > If I patch the linker source, how would I rebuild and reinstall > pkg/tool/.../link ? I think there are two options: - Learn how to make the distro's package from

[go-nuts] Re: Migrating Google App Engine Go app to Go 1.12

2019-09-30 Thread Jan Mercl
On Mon, Sep 30, 2019 at 11:32 AM Jan Mercl <0xj...@gmail.com> wrote: Panic mode off. Deployed, seems to work: https://gitlab.com/cznic/modernc/commit/96339947ba67960ae5bd19b625b2816fdcc7af6e Thanks to anyone who have read the OP. -- You received this message because you are subs

Re: [go-nuts] Migrating Google App Engine Go app to Go 1.12

2019-09-30 Thread Jan Mercl
On Mon, Sep 30, 2019 at 12:34 PM Matthew Zimmerman wrote: > > My notice said that apps continue to run, you just can't deploy new versions. > > "Starting on October 1, 2019, as per our deprecation policy, you will no > longer be able to deploy new versions of App Engine Standard applications >

[go-nuts] Migrating Google App Engine Go app to Go 1.12

2019-09-30 Thread Jan Mercl
Hi list. The modernc.org domain go-get redirector is hosted at the Google App Engine and provides access to all packages found at this time at https://gitlab.com/cznic. Go code for the redirector iself is published at https://gitlab.com/cznic/modernc. The instance dashboard shows a warning: "A

Re: [go-nuts] nil map assignment panics. can we do better?

2019-09-24 Thread Jan Mercl
On Tue, Sep 24, 2019 at 10:11 PM Marcin Romaszewicz wrote: > > Could we have an operation like append() for slices? > > How about: > > m := insert(m, "key", "value"). A slice is a value but a map is implemented as a pointer. IOW, the line of code quoted above updates only the locally visible

Re: [go-nuts] Clarification on unsafe conversion between string <-> []byte

2019-09-23 Thread Jan Mercl
On Mon, Sep 23, 2019 at 11:37 AM wrote: > ... and the problems with storing a uinptr in a variable are mostly related > to moving garbage collectors ... Please note that even though, AFAIK, none of the Go compilers so far uses a moving GC, it's not the only source of objects being moved

Re: [go-nuts] Re: v1.13: Altered go.mod file in project after updating vim-go binaries

2019-09-05 Thread Jan Mercl
On Thu, Sep 5, 2019 at 8:51 PM Mihai Borobocea wrote: > $ go help module-get > The 'go get' command changes behavior depending on whether the > go command is running in module-aware mode or legacy GOPATH mode. > … > Get resolves and adds dependencies to the current development module > and then

Re: [go-nuts] Re: v1.13: Altered go.mod file in project after updating vim-go binaries

2019-09-05 Thread Jan Mercl
On Thu, Sep 5, 2019 at 8:18 PM wrote: > Running 'go get ...' inside a module can add indirect dependencies to go.mod. I'm surprised. There's probably some rationale behind `go get` having such side effects. Can anyone please shed some light on this? -- You received this message because you

Re: [go-nuts] How to execute a command using root?

2019-08-30 Thread Jan Mercl
On Fri, Aug 30, 2019 at 8:53 AM Jan Mercl <0xj...@gmail.com> wrote: > Moreover, it should not be possible. But whitelisting certain users to run certain programs using sudo, but no password, is possible. -- You received this message because you are subscribed to the Google Groups &qu

Re: [go-nuts] How to execute a command using root?

2019-08-30 Thread Jan Mercl
On Fri, Aug 30, 2019 at 8:49 AM Benjamin wrote: >Do anyone have any suggestions on this? Thanks. IINM, what you want is not possible. Moreover, it should not be possible. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread Jan Mercl
On Sat, Aug 24, 2019 at 5:25 AM Lee Rick wrote: > > i want to do > type A struct{ Name string} > type B struct{Age int} > type C struct{Address string} > > a, b, c := A{}, B{},C{} > have a function > d1 := merge(a,b) //d1 like struct{Name string, Age int} > d2 := merge(a,c) //d2 like

Re: [go-nuts] Go string and UTF-8

2019-08-20 Thread Jan Mercl
On Tue, Aug 20, 2019 at 3:17 PM Pierre Durand wrote: > > Well, in my case I don't want to convert the []byte to hexadecimal string, > because it uses 2x more memory. > The code contains a huge map where the key is an MD5 hash. md5 hash is an array type and can be used as a map key directly:

Re: [go-nuts] Re: mutual exclusion algorithm of Dijkstra - strange behaviour

2019-08-16 Thread Jan Mercl
On Fri, Aug 16, 2019 at 8:09 PM wrote: > Meanwhile it is clear why things do not work: > The Go-Scheduler is unable to allow to switch to another goroutine in > busy-waiting-loops - > the only possibility to get around that problem is either to put > "switch-steps" into the source > - either

Re: [go-nuts] for i := range

2019-08-16 Thread Jan Mercl
One ranges a copy of the array, the other does not: https://play.golang.org/p/Z3InmyFqQN3 On Fri, Aug 16, 2019, 19:11 Vadim Maximov wrote: > Hi, all! > > Is *for.*..*range* over an address/reference of an array faster than > regular *for...range*? For instance: > > arr :=[...]int{1,2,3} > for

Re: [go-nuts] Re: When doing "type X Y", is it a type alias or type redefinition or type adapter or something else?

2019-08-13 Thread Jan Mercl
On Tue, Aug 13, 2019 at 9:24 AM Volker Dobler wrote: > Yes, of course. It declares a new named type X, the underlying > type is Y which can be some predeclared type like int, some > other named declared type (like MyFooType) or a "type literal" > (a term I made up) like struct{X,Y float64; T

Re: [go-nuts] how to pass c array to golang efficiently

2019-08-07 Thread Jan Mercl
On Wed, Aug 7, 2019 at 3:17 AM hui zhang wrote: > //export Send > func Send(confid string, len int, pcm *C.short) { >//put c.short array to int16 slice/array efficiently , how ? >// memcopy ? > } s := (*[^uint(0) >> 1]int16)(unsafe.Pointer(pcm))[:len] // s is []int16, len(s) = len --

Re: [go-nuts] Re: Question re fcns that return multiple values

2019-08-06 Thread Jan Mercl
On Tue, Aug 6, 2019 at 4:07 PM wrote: > > Here a specific example: > > The following compiles and runs as expected > m1x,m1y := ec.scalarMult(16,28,33) > m2x,m2y := ec.scalarMult( 1,28,33) > rx,ry := ec.add (m1x,m1y, m2x, m2y) > > > However this stmt :rx,ry= ec.add(ec.scalarMult(16,28,33),

Re: [go-nuts] Go Library lists

2019-08-06 Thread Jan Mercl
On Tue, Aug 6, 2019 at 3:51 PM wrote: > If anyone knows of a currently maintained equivalent , please respond Check https://github.com/golang/go/wiki/Projects -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] how to pass c array to golang efficiently

2019-08-06 Thread Jan Mercl
On Tue, Aug 6, 2019 at 11:11 AM hui zhang wrote: Please always send code to the ML as plain, black on white text. And/or use play.golang.org. Thanks. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Hexadecimal floats

2019-07-27 Thread Jan Mercl
On Sat, Jul 27, 2019 at 7:44 AM Adrian Ho wrote: It works: https://gitlab.com/cznic/qbe/commit/0cdebdce50edb146df981b6b484bad57eddb9e94#97b5d71a8f6b71eb5bf032969fb4a29f9d89eef4_1175_1177 Thanks again. -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Hexadecimal floats

2019-07-26 Thread Jan Mercl
There are several NaNs, but only a single bit pattern for IEEE754 infinity (modulo the sign bit). So yes, your suggestion should work well. Thank you, I'll give it a try. On Sat, Jul 27, 2019, 07:44 Adrian Ho wrote: > On 26/7/19 9:20 PM, Jan Mercl wrote: > > In a program that generat

Re: [go-nuts] Need explaination for code

2019-07-26 Thread Jan Mercl
On Fri, Jul 26, 2019 at 8:15 PM thatipelli santhosh wrote: > Can anyone please explain this piece of code? this would be more helpful to > me to understand this. Thank you! I don't know what "explain this code" means in this case. But maybe this can help: https://play.golang.org/p/t4yDlOwG-rv

[go-nuts] Hexadecimal floats

2019-07-26 Thread Jan Mercl
In a program that generates C, I'm using big.Float.Text (https://golang.org/pkg/math/big/#Float.Text) to produce the exact value of the C floating point literal. As it turns out, the function does not support Inf values. Instead of encoding the exact bits of the Inf value, the resulting string is

Re: [go-nuts] Re: About the Google logo on the new Go website

2019-07-20 Thread Jan Mercl
On Fri, Jul 19, 2019 at 10:39 PM Cassandra Salisbury wrote: > > I encourage everyone to take a look at the code of conduct. I have had > multiple reports from this particular thread. I, for one, have no idea why. But I guess Kafka would be delighted by this mysteriosity. -- You received this

Re: [go-nuts] Get struct type , save and reconstruct empty struct later

2019-07-20 Thread Jan Mercl
On Sat, Jul 20, 2019 at 9:28 AM Vasiliy Tolstov wrote: > Hi. I have reflection based question. > I need to store type of struct passed to func and later based on this stored > type reconstruct empty needed struct. > Does this possible ? Not sure I understood the question:

Re: [go-nuts] sqlite x ql

2019-07-17 Thread Jan Mercl
On Wed, Jul 17, 2019 at 4:34 PM Luis Furquim wrote: > Has anyone any information about performance comparison between Sqlite and Ql > (github.com/cznic/ql or modernc.org/ql)? Any bit of information would be > appreciated! QL is slower. Sometimes dramatically slower. QL's query

Re: [go-nuts] "Go to" one line before the declaration

2019-07-17 Thread Jan Mercl
On Wed, Jul 17, 2019 at 11:24 AM wrote: > > Can somebody explain this code? > How is the cpu doing? better than for{} ... Who claims it's doing better than `for {}`? IDK, I haven't tested, but I guess it should perform the same bad way. > ... and select {} in CPU usage? Now that's a different

Re: [go-nuts] Re: About the Google logo on the new Go website

2019-07-17 Thread Jan Mercl
On Wed, Jul 17, 2019 at 8:07 AM Michael Jones wrote: > > I'm a reader here, so @all includes me. In regards to Oracle, I was delighted > when they released VirtualBox under GPL and remain delighted that they pay > Oracle employees to enhance it and share their work. I'm a thankful user of

Re: [go-nuts] Question about iterator implementation of golang map

2019-07-15 Thread Jan Mercl
On Mon, Jul 15, 2019 at 4:39 PM Aaron Lau wrote: > We won't update the map during the traversal process. So why use mapaccessK > to find the k & v again ? The comment explains that very clearly: > // The hash table has grown since the iterator was started. > // The golden data for this key is

Re: [go-nuts] Tools or debug options for debugging 'Error in `bin/main': double free or corruption (fasttop)' in cgo

2019-07-14 Thread Jan Mercl
On Sun, Jul 14, 2019 at 5:03 PM Nitish Saboo wrote: > Can some please share the details of tools or Debug options to debug the > following error in cgo: Log allocations, log frees. From the log you'll know at which line of code the error was triggered. 'Log' can be as simple as printing to

Re: [go-nuts] Re: `on err` alternative to `try()` has traction...?

2019-07-09 Thread Jan Mercl
On Tue, Jul 9, 2019 at 2:03 PM Henrik Johansson wrote: > > Not sure if anyone has already mentioned the possibility that "try" could > actually improve error handling > by simply removing much of the tediousness. Both reading and writing all the > error checks becomes a > nail in my eyes even

Re: [go-nuts] Re: `on err` alternative to `try()` has traction...?

2019-07-09 Thread Jan Mercl
On Tue, Jul 9, 2019 at 1:48 PM Nicolas Grilly wrote: > The goal of the try proposal is not to "save a few keystrokes". The goal is > to reduce error handling verbosity when reading code. It's not verbosity. It's error handling. And because error handling is usually not the happy path, it's

Re: [go-nuts] return error

2019-07-09 Thread Jan Mercl
On Tue, Jul 9, 2019 at 11:05 AM sasikala tholisam wrote: > > var timingDefinitionInt int > timingDefinitionInt, err = strconv.Atoi("2") > if err != nil { > log.Fatalln("file format is incorrect!", err) > } > > errors are just being logged using log.Fatalln(). Instead,

Re: [go-nuts] Go 2018 Survey "Error handling 5%"

2019-07-08 Thread Jan Mercl
On Mon, Jul 8, 2019 at 3:48 PM Chris Passas wrote: > > Number 4,5,6 on the list all are listed at 5% so that's why I said "tied" for > 4th. Sorry, you're right. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

Re: [go-nuts] Go 2018 Survey "Error handling 5%"

2019-07-08 Thread Jan Mercl
On Mon, Jul 8, 2019 at 3:33 PM Chris Passas wrote: > > We are all aware error handling was tied for 4th most common challenging when working with Go in the 2018 survey. [image: image.png] It's 5th, not 4th. (src: https://blog.golang.org/survey2018-results) -- You received this message because

Re: [go-nuts] Re: gofmt: one line if statement

2019-07-05 Thread Jan Mercl
On Fri, Jul 5, 2019 at 11:55 AM Malcolm Gorman wrote: > If these single-statement if statements could be: > > if err != nil { return , err } > > the visual appearance of code would become far more compact and easier to > read, and we wouldn't need any special new syntax. I prefer the opposite.

Re: [go-nuts] Re: Announcing gg ("gigi") your new friend

2019-07-04 Thread Jan Mercl
$ go get ... On Thu, Jul 4, 2019, 19:23 'Niko Schwarz' via golang-nuts < golang-nuts@googlegroups.com> wrote: > What's your recommended strategy for installing it on linux? I guess it'll > take a few years before distributions have easy-to-install packages just > listed in their indices. > > On

Re: [go-nuts] Counter-counter-counter proposals

2019-06-30 Thread Jan Mercl
On Mon, Jul 1, 2019 at 4:50 AM Michael Jones wrote: > ... language design is about other people and other use cases than your own. That nicely explains C++ existence. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] The "leave "if err != nil" alone?" anti-proposal

2019-06-30 Thread Jan Mercl
On Sun, Jun 30, 2019 at 3:19 PM Jesper Louis Andersen wrote: > This is where the try-construct will definitely improve the ergonomics of the > programming. With full respect to you opinion and/or personal preferences, "definitely improve" is just and only that. I _definitely_ don't share that

Re: [go-nuts] What is the fundamental unit of linking in Go?

2019-06-28 Thread Jan Mercl
Please provide a minimal, self contained demonstration code that reproduces the problem. Then it should be hopefully easy to either explain why things work they do or it'll be a nice test case for the fix to the issue this may actually be. Thanks. On Fri, Jun 28, 2019, 20:10 wrote: > I have

Re: [go-nuts] Do I pass nil arguments method ?

2019-06-19 Thread Jan Mercl
Are you using some machine translator? Many sentences in the article make little sense. Some others do, but are either incorrect or the use wrong terminology. Also capitalization of some words is not right. Please do not post links to your blog to this mailing list, thank you. On Wed, Jun 19,

Re: [go-nuts] Re: is there a goroutine scope global veriable ?

2019-06-19 Thread Jan Mercl
On Wed, Jun 19, 2019 at 11:15 AM hui zhang wrote: > Is there a golang context way to do it? Some bits are at https://golang.org/pkg/context/#pkg-examples -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Re: is there a goroutine scope global veriable ?

2019-06-19 Thread Jan Mercl
On Wed, Jun 19, 2019 at 10:41 AM hui zhang wrote: > but, very few document mention , how to do it as goroutine local storage . > Can anyone give an example to solve my problem , refer the code I attached? Make the goroutine a method of a struct that contains any context the goroutine needs.

Re: [go-nuts] Re: is there a goroutine scope global veriable ?

2019-06-19 Thread Jan Mercl
On Wed, Jun 19, 2019 at 4:55 AM hui zhang wrote: > is there a goroutine scope global veriable ? so I can do this ? Go has no global scope. The closest is universe scope but that scope contains only predeclared identifiers. I think you are meaning package scope. Goroutines can access

Re: [go-nuts] Scheduling - find the overlap size of two sequential date ranges and determine the actual dates of included in the intersection

2019-06-17 Thread Jan Mercl
On Sun, Jun 16, 2019 at 6:48 PM John More wrote: > I have created a program to solve this problem > (https://play.golang.org/p/BueQBahUUbk) but I am not a pro and do not know if > there is a better way. Possibly useful: https://godoc.org/modernc.org/interval#example-Time -- You received

Re: [go-nuts] Newbie question on slice bound checking

2019-06-16 Thread Jan Mercl
On Sun, Jun 16, 2019, 13:53 Ugorji Nwoke wrote: > I know this is an old thread, but is -B still supported? > That compiler flag provides compiling a program, semantic of which isn't compatible with the Go language specification. It's only valid use is to enable easy evaluation of the bounds

Re: [go-nuts] Re: Go will shine on huge web projects, but how about simple ones?

2019-06-13 Thread Jan Mercl
On Thu, Jun 13, 2019 at 4:47 PM Tong Sun wrote: If you want or need to discuss personal feelings, please do it off-list. Thank you. -- 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

[go-nuts] Re: Proposal: disallow "fall through" to a labeled statement #32565

2019-06-12 Thread Jan Mercl
> Disallowing unintended fall throughs into labeled sections of a block will prevent a class of stupid errors. I'm stupid and I know it. Yet, it seems I haven't made this kind of error in the last ten years of Go. Maybe I'm just lucky. Or maybe this kind of error is rare. But if it's rare then a

Re: [go-nuts] Allow methods on primitives

2019-06-10 Thread Jan Mercl
On Mon, Jun 10, 2019, 13:07 Jesper Louis Andersen < jesper.louis.ander...@gmail.com> wrote: > At some point, it is going to be "generally accepted" at which point > languages without sum types are going to be regarded as a relic of the > past. > I hope to be dead for a long time then. Don't get

Re: [go-nuts] 【Go Specification fix proposal】about ConstSpec = IdentifierList [ [ Type ] "=" ExpressionList ] .

2019-05-31 Thread Jan Mercl
On Fri, May 31, 2019 at 9:52 PM wrote: > because const declaration cannot omit value. https://play.golang.org/p/gLlHpdpniTg -- 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

Re: [go-nuts] reflect Call method on nested struct

2019-05-29 Thread Jan Mercl
On Wed, May 29, 2019 at 9:42 AM Sotirios Mantziaris wrote: > I am getting the nested "Name" struct but there are no methods to call. > What am i doing wrong (besides using reflection :))? The method has a pointer receiver: https://play.golang.org/p/qjhqSvhE9PL -- You received this message

Re: [go-nuts] Test a Golang API on the web

2019-05-27 Thread Jan Mercl
On Mon, May 27, 2019 at 8:01 PM aimar wrote: > Would you please let me know, if there is any platform which I can test my > API online rather than localhost? (for free, of course) GCP free tier? -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Data race question in config package of harvester

2019-05-26 Thread Jan Mercl
On Sun, May 26, 2019 at 8:05 PM Sotirios Mantziaris wrote: > From what i understand you propose to create a new object and switch out the > old one with the new one using the atomic package of go. That cannot work. String is a multi word value. There's nothing in the atomic package that can

Re: [go-nuts] Stack based slice usage and unsafe

2019-05-26 Thread Jan Mercl
On Sun, May 26, 2019 at 5:30 PM Sergey Kamardin wrote: I'm not sure what the goal is, but the code looks like doing the same as just `bts := b[:]`. But then it's equal to just `bts := make([]byte, 16)`. Remember, there si no stack nor heap wrt the language specification, so there is no

Re: [go-nuts] Data race question in config package of harvester

2019-05-26 Thread Jan Mercl
On Sun, May 26, 2019 at 4:03 PM Sotirios Mantziaris wrote: > Let's assume that the string field Name has the value `Mr. Smith` and we > change this to `Mr. Anderson` in the goroutine, what are the possible values > that i could bet on a read? > > If these are either `Mr. Smith` or `Mr.

Re: [go-nuts] Data race question in config package of harvester

2019-05-26 Thread Jan Mercl
On Sun, May 26, 2019 at 3:45 PM Sotirios Mantziaris wrote: > Is there a chance that reading and assigning values might not be atomic? Accessing a the full multi word value is non-atomic on most, if not all architectures. -- You received this message because you are subscribed to the Google

Re: [go-nuts] Aggressive Golang Garbage Collection Issues When Using cgo?

2019-05-23 Thread Jan Mercl
On Fri, May 24, 2019 at 3:05 AM wrote: > > Unfortunately, after fitting the code with KeepAlive() calls (some probably > superfluous), the issues and their frequency have not notably changed. It did > allow me to remove the hack I had put in LockST() described in my original > note though.

Re: [go-nuts] Is there any difference between byte(a) and a in performance?

2019-05-23 Thread Jan Mercl
There will be a difference - once someone optimizes the 256 possible decadic representations of a byte as an array of hardcoded strings in the fmt package ;-) On Thu, May 23, 2019, 18:25 гусь wrote: > a = 'a' > fmt.Println(a) > > fmt.Println(byte(a)) > > -- > You received this message because

Re: [go-nuts] Re: io.Copy and Writer

2019-05-22 Thread Jan Mercl
On Wed, May 22, 2019 at 3:15 PM Ian Lance Taylor wrote: > > The bufio.Writer is badly broken and should be changed to declare Close and > > pass this to the contained Writer if it is a WriterCloser. > > What to open a proposal for that? https://golang.org/s/proposal. As I cannot vote on

Re: [go-nuts] cgo libnice binding will stuck

2019-05-22 Thread Jan Mercl
On Wed, May 22, 2019 at 10:05 AM xiang liu wrote: Please use only plain text for source code in emails. Where available, a link to play.golang.org is also good. Thanks. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] Re: io.Copy and Writer

2019-05-21 Thread Jan Mercl
On Tue, May 21, 2019 at 9:44 AM wrote: > Usually though, you do not need to buffer the input or output at all. If I/O is performed in chunks comparable in size to what bufio.{Reader,Writer} uses then ok. When I/O is done in small chunks, then using bufio should improve performance. The

Re: [go-nuts] constatnt conversion question

2019-05-20 Thread Jan Mercl
On Mon, May 20, 2019 at 11:33 AM wrote: > > Hi, > does this should work ? The error is correct. See https://golang.org/ref/spec#Conversions A constant value x can be converted to type T if x is representable by a value of T. An integer cannot represent the value 6.6 hence the

Re: [go-nuts] the Dominance of English in Programming Languages

2019-05-17 Thread Jan Mercl
On Fri, May 17, 2019 at 10:51 PM Andy Balholm wrote: > That’s probably true of the spoken language; American spelling, on the other > hand, has changed more than British spelling. This is mostly a result of Noah > Webster’s attempts to simplify it. > > King James Version Bibles generally

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Jan Mercl
On Fri, May 17, 2019, 19:09 Matt Layher wrote: > Thanks for the insight, this is very useful information. Perhaps I'll look > into the mmap route. > Possibly useful: https://godoc.org/modernc.org/memory -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] How to run a go method on multiple cores ?

2019-05-07 Thread Jan Mercl
On Tue, May 7, 2019 at 11:27 AM Nitish Saboo wrote: > I want to initialise parsing engines on two different processors. Are goroutines meant where we read 'processors'? If not, than this maybe is an XY problem[0] and please explain why you need distinct CPUs to execute the code. [0]:

Re: [go-nuts] Accessing css and js files in HTML served by Go

2019-05-06 Thread Jan Mercl
On Mon, May 6, 2019 at 6:11 PM ThisEndUp wrote: That listing is terrible. Colors aside, some parts of text has contrast like 10%. Please post source code/snippets at play.golang.org or include in in the email as plain text only, i.e.black on white. It's the most readable option. Thanks. -- You

Re: [go-nuts] How to run a go method on multiple cores ?

2019-05-06 Thread Jan Mercl
On Mon, May 6, 2019 at 1:39 PM Nitish Saboo wrote: > type Y struct { > > M string > N string > > } > > func initalize() Y{ > // I have a func that return an object ob type Y. > } > var obj1 Y = go initalize() No need to write Y above, the type will be inferred. However, see

Re: [go-nuts] How to run a go method on multiple cores ?

2019-05-06 Thread Jan Mercl
On Mon, May 6, 2019 at 1:11 PM Nitish Saboo wrote: > > Hi, > > I want a go method to run on multiple cores.The go method is returning an > object. Can we achieve this using goroutine ? > How can I achieve this ? In the first approximation, to run a a function/method f() in a goroutine on N

Re: [go-nuts] Enabling go's race detector working over SQL barrier

2019-05-06 Thread Jan Mercl
On Mon, May 6, 2019 at 6:56 AM Neven Miculinić wrote: > Is there some project going into this direction? Not sure if relevant: https://godoc.org/modernc.org/ql -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] request for feedback on this channel based waitgroup

2019-05-05 Thread Jan Mercl
On Sun, May 5, 2019 at 9:56 PM Louki Sumirniy wrote: > > I think the key thing is the Add function I have written is not concurrent > safe. I didn't intend it to be as I only had the use case of a single thread > managing a worker pool, and I am pretty sure it is fine for this and for > larger

Re: [go-nuts] request for feedback on this channel based waitgroup

2019-05-05 Thread Jan Mercl
On Sun, May 5, 2019 at 12:54 PM Louki Sumirniy wrote: > > hang on, sorry to be so chatty on this but I'm learning a lot about handling > edge cases from this, so I need to comment further > > ok, I got it working for that test also: > > https://play.golang.org/p/nd_EuCSOWto > > I can tell by the

Re: [go-nuts] request for feedback on this channel based waitgroup

2019-05-05 Thread Jan Mercl
On Sun, May 5, 2019 at 12:45 PM Louki Sumirniy wrote: > > https://play.golang.org/p/5KwJQcTsUPg > > I fixed it. Not really. You've introduced a data race. jnml@4670:~/src/tmp> cat main.go package main type WaitGroup struct { workers int ops chan int } func New() *WaitGroup

Re: [go-nuts] request for feedback on this channel based waitgroup

2019-05-05 Thread Jan Mercl
On Sun, May 5, 2019 at 12:45 PM Louki Sumirniy wrote: > The code you have written there has weird non-standard utf-8 code points in > it. It was plain ASCII only. You can verify that here: https://groups.google.com/forum/#!original/golang-nuts/r3N6bM8YnIg/aEYX1qViBAAJ -- You received this

Re: [go-nuts] request for feedback on this channel based waitgroup

2019-05-05 Thread Jan Mercl
On Sun, May 5, 2019 at 12:06 PM Louki Sumirniy wrote: > Is there ANY other use case for waitgroup other than preventing a goroutine > leak or ensuring that it empties the channels at the end of execution? I don't think this question is related to the correctness of your shorter implementation

Re: [go-nuts] request for feedback on this channel based waitgroup

2019-05-05 Thread Jan Mercl
On Sun, May 5, 2019 at 11:46 AM Louki Sumirniy wrote: > That would mean your code, which breaks this code, also breaks the rule about > never starting a goroutine without having a way to stop it. My code only > fails when the caller is also failing. My code does not even contain a go

Re: [go-nuts] request for feedback on this channel based waitgroup

2019-05-04 Thread Jan Mercl
On Sat, May 4, 2019 at 11:22 PM Louki Sumirniy wrote: > The first thing you will notice is that it is a LOT shorter. It fails a simple test: https://play.golang.org/p/v3OSWxTpTQY The original is ok: https://play.golang.org/p/OhB8qZl2QLQ Another problem is starting a new goroutine per

Re: [go-nuts] cgo compile error: array type has incomplete element type

2019-05-04 Thread Jan Mercl
On Sat, May 4, 2019 at 6:53 PM T L wrote: > BTW, the type bar is defined as > > typedef struct bar bar; If struct bar is not yet defined at that point then it's an incomplete type. So is bar. Not sure if calling an incomplete type 'defined' makes sense. However, this should be IMO ok

Re: [go-nuts] cgo compile error: array type has incomplete element type

2019-05-04 Thread Jan Mercl
On Sat, May 4, 2019 at 2:15 PM T L wrote: > But it is a pointer parameter, though it looks like an array. Yes, a pointer to an incomplete type. The compiler thus does not know how to compute address of bars[x] as that translates to bars + x*sizeof(bar). -- You received this message because

Re: [go-nuts] cgo compile error: array type has incomplete element type

2019-05-04 Thread Jan Mercl
On Sat, May 4, 2019 at 12:57 PM T L wrote: > > > In one of my cgo project, there is a c API (a c++ wrapper) like > > bool foo(bar bars[2]); > > It fails to compile with error message: > > error: array type has incomplete element type 'bar' {aka 'struct bar'} Incomplete type has uknown size. You

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Jan Mercl
On Fri, May 3, 2019 at 5:14 PM Louki Sumirniy wrote: > If the 'letter' classification is the same as used in .NET's unicode > implementation, this info lists the categories of symbols that unicode > classifies as letters: https://golang.org/ref/spec#Characters In The Unicode Standard

Re: [go-nuts] Is it possible to simplify this snippet?

2019-05-01 Thread Jan Mercl
On Wed, May 1, 2019 at 2:37 PM гусь wrote: > > if rl.IsKeyDown(rl.KeyA) { > p.Rect.X -= 1 > } > if rl.IsKeyDown(rl.KeyD) { > p.Rect.X += 1 > } > if rl.IsKeyDown(rl.KeyW) { > p.Rect.Y -= 1 > } > if rl.IsKeyDown(rl.KeyS) { > p.Rect.Y += 1 > } A switch statement would be perhaps more readable and

Re: [go-nuts] Map inside a struct

2019-04-30 Thread Jan Mercl
On Tue, Apr 30, 2019 at 4:31 PM wrote: > In the method, I can debug and see that the struct got created with map and > its key value pair, however when the method returns to the caller, the struct > is there PI and cat initialised, but the key value pairs disappear from the > map. Is this

Re: [go-nuts] Pass value from C code to GO code(CGO)

2019-04-26 Thread Jan Mercl
On Fri, Apr 26, 2019 at 12:54 PM Nitish Saboo wrote: > Can I pass a pointer to a value from Go to C, do some manipulation on it > within the C code and access the value from Go after the C code executes ? The first part of the question is discussed in great detail here:

Re: [go-nuts] Pass value from C code to GO code(CGO)

2019-04-26 Thread Jan Mercl
On Fri, Apr 26, 2019 at 12:34 PM Nitish Saboo wrote: > > Hi, > > I want to call C code from GO code.Once the C code gets executed I want to > pass the value back to the GO code. > Can someone please guide me as in how to pass value back from C code to the > GO code. What C type the value is?

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-25 Thread Jan Mercl
On Thu, Apr 25, 2019 at 8:58 PM wrote: > > Rob : how can it be abused if the compiler wont allow nested ? operators ?? Rather easily. Just by fuzzilly mixing the otherwise purposely distinct syntax of expressions and control flow. -- You received this message because you are subscribed to the

Re: [go-nuts] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 4:16 PM Nitish Saboo wrote: > >>Why size_t, char is going to be undefined here ? I followed the exact steps > >>mentioned in 'https://github.com/golang/go/wiki/cgo#function-variables' > >>under the topic 'Function pointer callback'. > I have to pass the callback

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 3:48 PM L Godioleskky wrote: > > The lack of a Go ternary operator is at odds with Go's major theme of clean > and easy to read syntax. Those who choose not to use the ternary operator can > always resort back to Go's current 'if -else' or 'case' syntax. So Go syntax >

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 2:04 PM Mark Volkmann wrote: > The idea of adding the ternary operator to Go has been debated many times. > It’s clear that those in charge have a strong dislike for it. For me the lack > of the ternary operator is one of main things I dislike about Go. It’s nails > on

Re: [go-nuts] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 1:51 PM Nitish Saboo wrote: > > Hi, > > I followed the link > 'https://github.com/golang/go/wiki/cgo#function-variables' and made the > following changes: > 1)main.go > package main > //#cgo CFLAGS: -I./syslog-ng-3.6.2/ > //#cgo LDFLAGS: syslog-node.so > //#cgo LDFLAGS:

Re: [go-nuts] cannot use CallBack (type func(*_Ctype_char, *_Ctype_char, _Ctype_ulong)) as type *[0]byte in argument to _Cfunc_reload_pattern_db

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 10:47 AM Nitish Saboo wrote: > ./main.go:80:32: cannot use key (type *_Ctype_char) as type string in map > index func CallBack(ckey *C.char, value *C.char, value_len C.size_t){ key := C.GoString(ckey) if remap, ok := field_mappings[key]; ok {

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Jan Mercl
On Wed, Apr 24, 2019 at 3:05 AM wrote: > > It sure would be nice if Go syntax allowed programmers to replace > > if ( test) { > ...do sonething > } That's not how Go's if statement looks. Gofmt will remove the superficial parentheses around 'test'. Wrt the rest of the proposal, today, this is

Re: [go-nuts] Re: methods on C types

2019-04-18 Thread Jan Mercl
On Thu, Apr 18, 2019 at 6:07 PM Jamil Djadala wrote: > > On Thu, 18 Apr 2019 07:44:53 -0700 (PDT) > peterGo wrote: > > > Cgo translates C types into equivalent unexported Go types. > > https://golang.org/cmd/cgo/ > > > But then, definition of new methods on non-local types is forbidden. > Why it

Re: [go-nuts] floating point question

2019-04-15 Thread Jan Mercl
On Mon, Apr 15, 2019 at 6:47 PM Miki Tebeka wrote: > Does that mean that the Go compiler is using floats with more precision than the runtime? Absolutely: https://golang.org/ref/spec#Constants Represent integer constants with at least 256 bits. Represent floating-point constants,

Re: [go-nuts] floating point question

2019-04-15 Thread Jan Mercl
On Mon, Apr 15, 2019 at 11:19 AM Miki Tebeka wrote: > Can anyone explain the below? a and b have 64b precision and they are assigned the same value, after that value is rounded to the lower precision. 1.1*1.1 and 1.21 are untyped constants and have much higher precision at which they are not

Re: [go-nuts] The go way to compare values against an enum

2019-04-15 Thread Jan Mercl
On Mon, Apr 15, 2019 at 10:53 AM Sankar wrote: > I want to evaluate if the string variable `day` is one of the valid permitted values for the [Ww]eekday custom type. What is the recommended / right go way of doing this ? Go has no enums and type weekday has no permitted/not permitted values.

Re: [go-nuts] go test cover with args, coverage flag has been treat like an args.

2019-04-11 Thread Jan Mercl
On Thu, Apr 11, 2019 at 10:57 AM hui zhang wrote: > How to resolve this ? If you're not using any options in your program, just the arguments, you may do this: $ cat main.go package main import ( "flag" "fmt" ) func main() { flag.Parse()

Re: [go-nuts] Re: When slice decide to expand cap?

2019-04-11 Thread Jan Mercl
On Thu, Apr 11, 2019 at 12:21 PM jianfeng ye wrote: > > and i want to got the code where go build check slice's cap to decide where use growslice? You can find the source easily[x] but I think the more important question is why you need it. It's an implementation detail of the particular

Re: [go-nuts] how to use an instance across functions in a package w/o global vars

2019-04-11 Thread Jan Mercl
On Thu, Apr 11, 2019 at 11:56 AM Dumitru Ungureanu wrote: > > Secondly, as far as my knowledge goes: > > your example is declaring the function in place, it doesn't pass the > variable around to another function The `w` variable is visible in the closure. Closure is a function + closed over

Re: [go-nuts] how to use an instance across functions in a package w/o global vars

2019-04-11 Thread Jan Mercl
On Wed, Apr 10, 2019 at 7:23 PM Dumitru Ungureanu wrote: > > In this particular case, w.DefineFunction Api does not acomodate such a > passing. Please explain why and/or what do you mean by that as I don't see where/what the problem is. > Reason I asked in the first place. Dependency injection

Re: [go-nuts] how to use an instance across functions in a package w/o global vars

2019-04-10 Thread Jan Mercl
On Wed, Apr 10, 2019 at 2:42 PM Dumitru Ungureanu wrote: The alternative is to pass `w` around as a function argument. For that it will be necessary to create/initialize `w` in main or in a function call made from main. PS: Go has no global scope. The closest is universe scope, but programs

<    1   2   3   4   5   6   7   8   9   10   >