[go-nuts] Re: Deciding between better documentation or making a module harder to misuse

2023-11-19 Thread Travis Keep
nce you could have interfaces Sequence and FiniteSequence defined with > the same set of methods, except that FiniteSequence has an extra dummy > method like ReallyIsFinite(). It's never called, but is implemented by > FiniteNumber and not Number, for type checking purposes only. > > On

[go-nuts] Deciding between better documentation or making a module harder to misuse

2023-11-18 Thread Travis Keep
I have published this module: https://pkg.go.dev/github.com/keep94/sqroot/v2 for analysing square roots and cube roots. The module works, but it is easy to write code that will run forever. For example in v2: // Print the position of the last 7 in the square root of 2. Oops, the square root

[go-nuts] Memoization and Value types

2023-03-27 Thread Travis Keep
I have this package: https://pkg.go.dev/github.com/keep94/sqroot, which computes square roots to arbitrary precision. The Number type is a value type that represents a square root value. Early on it made sense to make Number be an immutable value type because it represents an immutable value

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

2022-10-22 Thread Travis Keep
The type I am writing can be easily encoded as a sequence of ints. When I wrote MarshalBinary for my type, I decided to GobEncode this sequence of ints to a byte buffer and return the bytes. I learned that GobEncoding an empty slice of int takes 18 bytes. So even for small instances of my

[go-nuts] Generics: Whats the best way around limitation that methods can't be parameterized

2022-01-20 Thread Travis Keep
I am working on a Pipeline[T, U any] type which receives any number of T values and in turn emits U values. Pipelines are used to read from databases. For instance, this code fetches the ages of 5 people under 50. int[] ages PeopleOrderedByName(Start[Person](). Map(func(p Person) int {

[go-nuts] Does pkg.go.dev understand packages that use generics?

2021-12-18 Thread Travis Keep
I created github.com/keep94/consume2 which is a rewrite of github.com/keep94/consume using Go generics. However, the new package is not showing up in pkg.go.dev. I am wondering if pkg.go.dev is set up to understand generics? -- You received this message because you are subscribed to the

[go-nuts] Can I play with go1.18 beta while keeping my stable 1.17 version around for production code?

2021-12-15 Thread Travis Keep
This may be silly question, but is there a way for me to download and play with 1.18 while keeping my existing 1.17 installation for production code? Is there a way to have multiple versions of go installed on the same computer? -- You received this message because you are subscribed to the

[go-nuts] pkg.go.dev question regarding selection of "Latest" version

2021-06-13 Thread Travis Keep
I recently checked in a new version of github.com/keep94/birthday on 12 June. pkg.go.dev sees this new version, yet pkg.go.dev insists that the "latest" version is the one I checked in on the 11 June. The version that I want to be the latest is: v0.0.0-20210612031622-805d2048defa

[go-nuts] Question about container/heap

2021-06-13 Thread Travis Keep
Recently I implemented a heap in GO. To implement a heap, you have to implement Push() and Pop() as well as the 3 methods for sort: Less(),, Swap(), and Len(). For my heap, I never had to Push or Pop, I only had to initialize the heap and repeatedly "Fix" the top element of the heap. As it

[go-nuts] The composite pattern in GO

2021-02-20 Thread Travis Keep
I am writing this to see what everyone thinks about a solution I have for the composite pattern. The composite pattern is when 0 or more instances of some interface X can act together as a single instance of interface X. For instance you may have a Filter interface that filters instances of

[go-nuts] Channels may not be the best solution in Go

2019-10-02 Thread Travis Keep
I've been working on a math library github.com/keep94/gomath. This library has functions for generating prime numbers, ugly numbers, harshad numbers, happy numbers etc. Since there are infinitely many prime numbers, ugly number, harshad numbers etc, these functions I wrote returned either a

[go-nuts] Go vendoring question

2017-10-31 Thread Travis Keep
Somebody I depend on for my project made a breaking change to their git repo and broke my build. I found that if I simply revert their latest commit locally that my project builds. I don't necessarily want to vendor everything because most of the libraries I use I trust. But I do want to