Re: [go-nuts] Announcing the tabula backgammon engine

2023-12-07 Thread Martin Schnabel
Hi Trevor, I played two games against the bot and it was fun! Thank you! However, there is a bug in the end game, when collecting pieces, and a go stack trace in the console: panic: no dice roll to use for 7/0 […] code.rocket9labs.com/tslocum/bgammon.(*Game).LegalMoves.func3(0x7, 0x0)

Re: [go-nuts] Re: recommended statistics package? Requirements: ANOVA, Brown-Forsythe

2023-10-23 Thread Martin Schnabel
Hi, I attempted to translate the linked JS implementation for fun. Maybe someone can use it as a starting point and correct or verify its correctness. https://go.dev/play/p/Wrw2yDRof0z Have fun! On 10/23/23 07:38, Jan wrote: hi, I did a quick search and I didn't find anything in Go. But

Re: [go-nuts] Map of types?

2023-04-12 Thread Martin Schnabel
Hi Bèrto, as you said, you cannot put a type directly into a map. However you can use package reflect to get type reflection information, that you can put into a map. But in this case I would simple use a map of constructor functions that have a common interface. Like this

Re: [go-nuts] Looking for new project that I can start right now

2023-02-12 Thread Martin Schnabel
discord id? Regards Kazuya On Saturday, February 11, 2023 at 4:28:46 PM UTC+9 Martin Schnabel wrote: Hey Kazuva, the readme describes mostly the problem and gives some ideas for the proposed solution. It is meant to hopefully convince artists and publishers (it will need some

Re: [go-nuts] Looking for new project that I can start right now

2023-02-10 Thread Martin Schnabel
Kazuya Nomura On Saturday, February 11, 2023 at 3:13:15 AM UTC+9 Martin Schnabel wrote: Hi Kazuva, I would actually have a basic idea and vague plans for a non-profit project for carving out some fair-use rights back for amateur musicians. The project already

Re: [go-nuts] Looking for new project that I can start right now

2023-02-10 Thread Martin Schnabel
Hi Kazuva, I would actually have a basic idea and vague plans for a non-profit project for carving out some fair-use rights back for amateur musicians. The project already has a great name qnpdub, but not yet any web presence other than a readme on github: https://github.com/mb0/qnpdub I

Re: [go-nuts] output slice without brackets

2023-01-14 Thread Martin Schnabel
Hi, if you have string slice you can use strings.Join(slice, ", "). Please do send text as text to mailing lists. Hope this helps, have fun! On 1/14/23 09:46, Nuraini putri wrote: Hi, I wanna ask about How to print slice output without brackets? DISCORD.png -- You received this message

Re: [go-nuts] How to cast *interface{} into *T ?

2022-11-25 Thread Martin Schnabel
On 11/25/22 10:55, Denis P wrote: Thank you everyone for your help. The problem still exists. I am looking for a solution where s and s2 point to the same instance. The current example proves they are different instances. https://go.dev/play/p/_JyfJelhIy4 The main goal is to store any type

Re: [go-nuts] What is the best way to write MarshalBinary if the data is a sequence of ints

2022-10-23 Thread Martin Schnabel
hi travis, if you can use any encoding you like, you can write your own custom encoding that uses a varint encoding. the binary encoding interface implies that the framing or length segmenting of the raw bytes happens outside that function, so you can just read and write all your ints using the

Re: [go-nuts] Facing issues while using builtin functions while executing golang templates

2022-10-22 Thread Martin Schnabel
Hi Ritesh, I am no expert on these matters, but have you thought about defective memory on this specific machine? I certainly looks very wrong to me and the first thing i would try is run an extensive memory test. If your systems memory is faulty, then all bets are off and trying to debug

Re: [go-nuts] Issue with go-git API

2022-10-10 Thread Martin Schnabel
Hi PK, most of the time examples are single file programs to be used with go run. if you are inside the module root that covers all the dependencies (or decend into the relevant example folder) you can use `go run main.go` to run the example file. I just tired it with the same repository

Re: [go-nuts] Re: Error-checking with errors.As() is brittle with regards to plain vs pointer types

2022-09-22 Thread Martin Schnabel
)   if ok {     return err, true    }   return err, false } https://go.dev/play/p/YoIjKtoynuI <https://go.dev/play/p/YoIjKtoynuI> On Thu, Sep 22, 2022 at 11:38 AM Martin Schnabel <mailto:m...@mb0.org>> wrote: Sorry, to barge in but this specific thing is not really an iss

Re: [go-nuts] Re: Error-checking with errors.As() is brittle with regards to plain vs pointer types

2022-09-22 Thread Martin Schnabel
Sorry, to barge in but this specific thing is not really an issue as long as you use the error type as result type. because any value with an Error() string method does implement the error interface. and even an empty struct or a nil pointer to a applicable type will do just fine an matches err

Re: [go-nuts] Assigning struct values

2022-09-08 Thread Martin Schnabel
Hi Mustafa, this can be easy if you put a pointer value of type *TypeOfStruct into the interface. interface values of structs end up using pointers underneath anyway so there is no performance reason not to. The explanation is that if you type assert to TypeOfStruct, you copy out that plain

Re: [go-nuts] Using Go Lang as a tiny server program at localhost , won't execute request

2022-08-05 Thread Martin Schnabel
hi john, other than php, go programs are compiled to an executable that can then be run. you can not put go files in a folder and expect that to work. you probably followed a tutorial to set up a go http server with a simple route. the reason you get that idea that you can use file names

Re: [go-nuts] Golang import issue .

2022-07-20 Thread Martin Schnabel
Hi Sunday, please do send neither screenshots nor zipped project folders to a mailing list of thousands. My guess is that your projects go.mod file does not declare your project name to be movie_project. In any case it would be helpful for you to follow a hello world tutorial:

Re: [go-nuts] Best way of implementing generic binary search?

2022-07-19 Thread Martin Schnabel
Hi, there is an experimental package golang.org/x/exp/slices which has a generic binary search. I have not much to add but hope it helps. https://pkg.go.dev/golang.org/x/exp/slices https://cs.opensource.google/go/x/exp/+/79cabaa2:slices/sort.go;l=64 On 7/19/22 14:53, Slawomir Pryczek wrote: Hi

Re: [go-nuts] ListenAndServeTLS() (pem and key files for private network)

2022-06-30 Thread Martin Schnabel
Sorry, i may have misunderstood the private network part, hope my answer was helpful anyway. My usecase was a local area network without a fixed ip or dns names, like common home network appliances. I thought about using client certificates too, but decided it would be easier to use common

Re: [go-nuts] ListenAndServeTLS() (pem and key files for private network)

2022-06-28 Thread Martin Schnabel
DELETE"},         AllowedHeaders:   []string{"*"},         AllowCredentials: true,     }) handler := c.Handler(r) On Tue, Jun 28, 2022 at 7:03 AM Hugh Myrie <mailto:hugh.my...@gmail.com>> wrote: Thanks Martin for your help. On Tue, Jun 28, 2022, 06:26 Martin Schn

Re: [go-nuts] ListenAndServeTLS() (pem and key files for private network)

2022-06-28 Thread Martin Schnabel
hi hugh, i played around with the same idea six years ago, resulting in https://github.com/mb0/localca it will use a self signed root cerificate and creates new child certificates specific to the requested hostname, be it an ip or a name like my_local.box i haven't tested it for awhile,

Re: [go-nuts] Generics

2022-05-27 Thread Martin Schnabel
not versed enough in go generics to know the solution, but would propose to take a simpler approach if possible. On 5/27/22 18:24, Martin Schnabel wrote: how about https://go.dev/play/p/YXOTLKpvXNI using json unmarshal directly and without using binary marshaller. or even https://go.dev/play

Re: [go-nuts] Generics

2022-05-27 Thread Martin Schnabel
how about https://go.dev/play/p/YXOTLKpvXNI using json unmarshal directly and without using binary marshaller. or even https://go.dev/play/p/GFE3rnyx9f8 without the endpoint abstraction. or maybe explain what you want to achieve other than unmarshalling a json payload? best regards On

Re: [go-nuts] How Does This Work?

2022-03-06 Thread Martin Schnabel
one important detail i have not found in the other answers is that stat is declared to return a fs.FileInfo, but printf takes an empty interface argument and therefor unwraps the interface value. so if you want to print the actual variable type of interface variables you can pass a pointer (same

Re: [go-nuts] Re: Questions about documentation of Go standard library

2021-10-08 Thread Martin Schnabel
Hi Kamil, you can probably read it as Invalid argument index or invalid use of argument index. Hope that helps. On 10/9/21 12:33 AM, Kamil Ziemian wrote: Hello, I now read documentation of "fmt" package and in "Format errors" (https://pkg.go.dev/fmt@go1.17.2#hdr-Format_errors) we have

Re: [go-nuts] Trouble with pgx package

2021-10-02 Thread Martin Schnabel
as http.HandlerFunc to pass to a router or mux. Have fun! On 10/2/21 3:53 PM, Martin Schnabel wrote: Hi Денис, QueryRow does not return an error but a Row that you then call Scan on which returns an error. https://pkg.go.dev/github.com/jackc/pgx/v4#Conn.QueryRow You usually call it in combination with scan

Re: [go-nuts] Trouble with pgx package

2021-10-02 Thread Martin Schnabel
Hi Денис, QueryRow does not return an error but a Row that you then call Scan on which returns an error. https://pkg.go.dev/github.com/jackc/pgx/v4#Conn.QueryRow You usually call it in combination with scan. err := QueryRow(`…`).Scan() Have fun! On 10/2/21 12:52 PM, Денис Мухортов wrote:

Re: [go-nuts] Question on handling Data Race

2021-09-12 Thread Martin Schnabel
hi Michael, from my understanding: if you only call refresh from somefunc and locking the body should be fine. however i strongly advise not to export refresh, otherwise it is a broken api. and someone, someday will call refresh without that lock. if refresh should be part of the accessible

Re: [go-nuts] Why do I get multiple times the same data?

2021-07-29 Thread Martin Schnabel
hey, your playground link does not compile! therefor you get a rot13 version of the fixed playground link: uggcf://cynl.tbynat.bet/c/_wwLujQtms- ;) Well who wants to be mean. Just move your buffer declaration into the for loop or reset it: https://play.golang.org/p/hGovCri02lc have fun On

Re: [go-nuts] I think I found a bug?

2021-05-26 Thread Martin Schnabel
Could you send a https://play.golang.org/ link showing a short example? Without much information it sounds like a you update the same slice at two different indices. It would be interesting to know how you populate the temp slice. On 27.05.21 01:52, John Olson wrote: I have a recursive

Re: [go-nuts] Search for directory named BigZoom and list contents.

2021-05-10 Thread Martin Schnabel
hi Adam, you call ReadDir with the file name and not with the full path or the path relative to your current working directory. that means you will try to read the dir with path "BigZoom" two times. the WalkDirFunc passes a path argument that concatenates the path prefix with the dir entry

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Martin Schnabel
n them now? On 13.03.21 14:09, Jan Mercl wrote: On Sat, Mar 13, 2021 at 1:44 PM Martin Schnabel wrote: as far as i know there is no reason that anybody has to write code with generics when they are available. therefor i really don't understand the negative mails to this list. That nonchalantly ignores

Re: [go-nuts] No generic, part -2

2021-03-13 Thread Martin Schnabel
(sorry space a, i didn't reply to list) hi alex and space a. as far as i know there is no reason that anybody has to write code with generics when they are available. therefor i really don't understand the negative mails to this list. do you also want others not to use them? how would that

Re: [go-nuts] Go Documentation for private github projects

2021-02-20 Thread Martin Schnabel
Hi, this January a fork of gddo was was announced to this list. Take a look https://godocs.io/ Best regards On 20.02.21 08:13, Sankar P wrote: Hi We have a bunch of private repos in github with Go sources. We want to see the documentation for these repository sources in an easy to click URL.

Re: [go-nuts] Possible Go 2 proposal for built-in Remove method for Slices.

2021-02-06 Thread Martin Schnabel
On 06.02.21 03:32, Wojciech S. Czarnecki wrote: Dnia 2021-02-04, o godz. 00:30:57 Selahaddin Harmankaya napisał(a): There are obviously more things to consider Slice is not an array, it is a _view_into_ an array. Many such views into the same array may exist simultaneously. A "remove

Re: [go-nuts] Generics - please provide real life problems

2020-12-31 Thread Martin Schnabel
hi Space, i do not care about this discussion in general and learned to trust the go developers to be thoughtful and reasonable. i wouldn't write this normally, but in case you are not aware it might actually help: i did read the last couple of your messages to this list again and came to

Re: [go-nuts] json objects

2020-12-26 Thread Martin Schnabel
hi hamsa, first of all: it is usually frowned upon to send text as pictures. so please copy text as text in the future. the are people with terminal mail clients or visually impaired using screen readers. the data in your example is neither valid json value nor a valid json stream. either

Re: [go-nuts] handling database.Query empty set

2020-09-13 Thread Martin Schnabel
sorry Andy, it seems i haven't read your example carefully enough. your question was what to do if the query returns multiple rows. i tried to explain that. however the query in your example looks like it will only ever return a single row, because you probably marked the username column in

Re: [go-nuts] handling database.Query empty set

2020-09-12 Thread Martin Schnabel
hi Andy, when you take a look at the documentation of the Rows type returned by Query you will see a helpful example of its common use, appending the scanned results into a slice. my recommendation would be to follow this example and then check if the len(slice) == 0 to detect an empty set.

Re: [go-nuts] writing to net.Conn tcp socket

2020-09-12 Thread Martin Schnabel
Hi Andy, a global map is the way to go, however writing an reading the map from multiple go routines will fail (in your case different handle calls for connections) because the map data structure is not safe for concurrent use and must be coordinated. the way it is usually solved is by adding

Re: [go-nuts] builtin function definitions

2020-07-29 Thread Martin Schnabel
The linked spec is the the definitive language specification. I read it carefully a couple of time (cannot recommend it enough) and knew about type switches. The most common language implementation is go's default compiler gc. Which is the place to implement the language spec and type

Re: [go-nuts] builtin function definitions

2020-07-29 Thread Martin Schnabel
This is a special kind of switch called a type switch. You can read more about it in the language specification where its part of the intrinsic go syntax. https://golang.org/ref/spec#Switch_statements Because it is a special language construct you need to look at the compiler. You probably

Re: [go-nuts] Busy synchronization wait seems to behave differently on 1.13 and 1.14

2020-07-25 Thread Martin Schnabel
I am not certain but the reason probably is the change to go-routine preemption in 1.14. From https://golang.org/doc/go1.14#runtime … Goroutines are now asynchronously preemptible. As a result, loops without function calls no longer potentially deadlock the scheduler or significantly delay

Re: [go-nuts] Weird benchmark results for seemingly identical functions

2020-06-22 Thread Martin Schnabel
Let me quickly point out that your logic is inverted in the second code snippet because you break on the condition. That is most likely the reason for the difference. I guess the second example exits on the first iteration. for pos := 0; true; pos++ { if pos < suffixLen && pos <

Re: [go-nuts] Weird slice of struct

2019-12-04 Thread Martin Schnabel
On 04.12.19 22:40, cstige...@gmail.com wrote: Hello Golang nuts group. I've tested golang's slice and got a weird result. Anyone can explain it? the variable ss in the for range loop is one and the same variable, with a different value of AA for each iteration. it has only one address.

Re: [go-nuts] Regarding strings replace functions issues

2019-08-28 Thread Martin Schnabel
. On 28.08.19 13:15, Martin Schnabel wrote: Somewhere in your code producing the text you seem to escape the the escape sequence for the newline character. "\n" is a string with the escape sequence for the newline character '\n' "\\n" is a string with escaped slash and a

Re: [go-nuts] Regarding strings replace functions issues

2019-08-28 Thread Martin Schnabel
Somewhere in your code producing the text you seem to escape the the escape sequence for the newline character. "\n" is a string with the escape sequence for the newline character '\n' "\\n" is a string with escaped slash and a lowercase n '\\' 'n' Again, without seeing the code we can only

Re: [go-nuts] Regarding strings replace functions issues

2019-08-27 Thread Martin Schnabel
You can use the go playground to share an example. Like this: https://play.golang.org/p/8RJXT-e91T5 As you can see in that example both functions work as expected. We can only guess what the problem might be without a concrete example. One guess would be that your input has not the newline

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

2019-07-20 Thread Martin Schnabel
If you only need any unnamed struct type you can create one with reflect from the field information that you can write to text somewhere. https://godoc.org/reflect#StructOf These unnamed struct types however do not have any methods and do not wrap embedded named type methods. Otherwise

Re: [go-nuts] get interface and method name

2019-07-12 Thread Martin Schnabel
Because AccountService.Create is a method expression you can get to the interface type by inspecting its first argument. Then you could check the interface type for all methods and compare the input and output parameters. This however is brittle and only works if you can guarantee that there is

Re: [go-nuts] Does invoking a method with an interface variable avoid dependency analysis?

2019-07-08 Thread Martin Schnabel
sorry. i misunderstood your question. the paragraph you quoted refers to reference to methods values (t.m) or expressions (T.m) and not method calls t.m() as in your example. does that help solve the question? On 08.07.19 20:09, Martin Schnabel wrote: On 08.07.19 02:51, Il-seob Bae wrote

Re: [go-nuts] Does invoking a method with an interface variable avoid dependency analysis?

2019-07-08 Thread Martin Schnabel
On 08.07.19 02:51, Il-seob Bae wrote: As per the spec , A reference to a method m is a method value or method expression of the form t.m, where the (static) type of t is not an interface type, and the method m is in the method

Re: [go-nuts] Citation Needed

2019-07-08 Thread Martin Schnabel
On 06.07.19 08:50, go je wrote: Is the Category "Games" gaining attention in the go community? Are the Developers writing for production level? Do we have an examples? image.png I would guess, that most of respondents using go for game development, use it on the server side. Think multi-,

Re: [go-nuts] Parsing time zone +07:00

2019-07-02 Thread Martin Schnabel
the format time uses a minus sign '-' instead of a plus https://play.golang.org/p/pXDXm0KmwTz have fun! On 02.07.19 20:11, 'Константин Иванов' via golang-nuts wrote: https://play.golang.org/p/4Rr2xVGKnQg | packagemain import( "fmt" "time" ) constin="+03:00"//

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-03 Thread Martin Schnabel
types", which is an important rule. Without qualification, this rule would be hard to express. On Mon, Jun 3, 2019, 15:26 Martin Schnabel <mailto:m...@mb0.org>> wrote: Hi Michal, I would argue that the 'const' keyword would by more correct. Because the array

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-03 Thread Martin Schnabel
d probably be better. Do you think that using the 'type' keyword also in the context of generic array lengths would be fine? On Mon, Jun 3, 2019, 12:53 Martin Schnabel <mailto:m...@mb0.org>> wrote: Hi, is my impression correct, that this proposal adds types as values to the

Re: [go-nuts] Go 2 generics counterproposal: giving up restricting types

2019-06-03 Thread Martin Schnabel
Hi, is my impression correct, that this proposal adds types as values to the language? It's seems like it does the section 'Unnamed generic arguments'. That by itself would go a long way and warrants some discussion, I'd say. If so, then why use a new keyword 'gen'? Why not 'type' itself.

Re: [go-nuts] parse timestamp in Go

2019-02-08 Thread Martin Schnabel
just for future reference, there is no format for 'this' (the format op asked for). because this format does not have a period. i was just as surprised. you can try yourself: https://play.golang.org/p/wv_PDwTmEOk the documentation also states that you do not specify the fraction seconds for

Re: [go-nuts] Re: Gracefully Shutdown File Server

2017-03-14 Thread Martin Schnabel
i looked into the issue and it seems the problem is the early exit from the program. this should work https://play.golang.org/p/LdXUYyzDxY On 14.03.2017 06:30, amk...@gmail.com wrote: Maybe this is a bug or need clear documentation about this. I've filed a bug report here:

Re: [go-nuts] Why does my program hang?

2017-02-26 Thread Martin Schnabel
big.NewInt(int64(unsafe.Sizeof(char also this line will will define the maximum of the random number which is 4. so all the random runes are 0 <= r <= 4 which are all not graphic. is this more what you expect https://play.golang.org/p/61hzuNj1nF it uses append instead of the

Re: [go-nuts] parse.ParseExpr("var a = 9") returns error "expected operand, found 'var'"

2016-08-11 Thread Martin Schnabel
On Do, 2016-08-11 at 03:55 -0700, Jason E. Aten wrote: > I'm trying to use parser.ParseExpr. I'm thinking "var a = 9" is a > valid expression, but ParseExpr returns an error: > hi jason,  a variable declaration is a statement and not an expression. when in question on this matters take a look at