Toy project to test golang toolset, using as pretext the "cyclic number" problem (famous 142857 number)

go-cyclic-number

Toy project to test golang toolset, using as pretext the "cyclic number" problem (famous 142857 number)

First version: https://github.com/amcajal/go-cyclic-number/commit/cabeb0c0102900ca0c0737e0054ba2776d8b98c7

First version just checks that the program produces the expected result. No test files (no TDD obviously), overkill decisions (the recursive function) and no insight about program performance. GDB was used to check how debugging in Go works. So far, it worked well. Need to take a look into delve The feedback provided by delve is quite misleading. An error "error layer=debugger can't find build-id note on binary" is reported when launching $> dlv debug; But it seems to work properly.

Second version: statements working as tests have been moved from "main.go" file to proper "_test.go" file. Creation of test cases is quite easy. Followed the tutorial at https://go.dev/doc/tutorial/add-a-test

Third version: a "resources usage" test is added to the cyclic_test.go, in order to retrieve profiling information. Profiling in go is quite easy with the "go test " and "go tool pprof". Profiling performed follown tutorial at https://golangdocs.com/profiling-in-golang

Fourth version: https://github.com/amcajal/go-cyclic-number/commit/9f9c322769e856a29e0f73eb1636b63ff9fe4e6b

In the fourth version, "IsCyclic" is modified, so instead of being a recursive function, it performs a plain for loop, generating the same results (but increasing the overall readability of the function). This change is good to test the TDD principles:

  • Test goes first: it is changed; Test does not compile (good)
  • Source code is modified; Test then compiles and still passing (good)

However, no performance improvements take place with this change.

Similar Resources

Golang in-memory database built on immutable radix trees

go-memdb Provides the memdb package that implements a simple in-memory database built on immutable radix trees. The database provides Atomicity, Consi

Jan 7, 2023

☄ The golang convenient converter supports Database to Struct, SQL to Struct, and JSON to Struct.

☄ The golang convenient converter supports Database to Struct, SQL to Struct, and JSON to Struct.

Gormat - Cross platform gopher tool The golang convenient converter supports Database to Struct, SQL to Struct, and JSON to Struct. 中文说明 Features Data

Dec 20, 2022

pure golang key database support key have value. 非常高效实用的键值数据库。

pure golang key database support key have value.  非常高效实用的键值数据库。

orderfile32 pure golang key database support key have value The orderfile32 is standard alone fast key value database. It have two version. one is thi

Apr 30, 2022

A simple memory database. It's nothing but a homework to learn primary datastruct of golang.

A simple memory database. It's nothing but a homework to learn primary datastruct of golang.

Nov 8, 2021

A rest-api that works with golang as an in-memory key value store

Rest API Service in GOLANG A rest-api that works with golang as an in-memory key value store Usage Run command below in terminal in project directory.

Dec 6, 2021

Shuffle bits in byte slice, written in golang

Shuffle 'em It is a library for bit shuffling, written in golang. The usecases a

Dec 27, 2021

The most concise and efficient algorithm of consistent hash based on golang

consistent This package of consistent is the most concise and efficient algorithm of consistent hash based on golang. Example Quick start: package mai

Dec 28, 2021

Rk-db - Enterprise level database bootstrapper with YAML based on rk-entry in Golang

rk-db Enterprise level database bootstrapper with YAML in golang. This belongs to rk-boot family. We suggest use this lib from rk-boot. Database Statu

Nov 16, 2022

Eagle - Eagle is a fast and strongly encrypted key-value store written in pure Golang.

EagleDB EagleDB is a fast and simple key-value store written in Golang. It has been designed for handling an exaggerated read/write workload, which su

Dec 10, 2022
Simple DB using yaml. A project for managing the content of yaml files.

DB Yaml Simple DB using yaml. A project for managing the content of yaml files. Table of Contents DB Yaml Features Usage Write to DB Query DB Get Firs

Dec 27, 2022
NoSql DB using fileSystems using golang

No SQL DB using Go Prerequisite go 1.15 Run test go test -v ./... Env Var Variable Description Default Value Possible Values DB_DATA dir location to s

Nov 8, 2021
Compare - Functions that help compare and output test results

compare Functions that help compare and output test results. How to use Compare(

Feb 16, 2022
The Monogon Project Monorepo. May contain traces of peanuts and a pure Go Linux userland.

This is the main repository containing the source code for the Monogon Project.

Jan 6, 2023
🤔 A minimize Time Series Database, written from scratch as a learning project.
🤔 A minimize Time Series Database, written from scratch as a learning project.

mandodb ?? A minimize Time Series Database, written from scratch as a learning project. 时序数据库(TSDB: Time Series Database)大多数时候都是为了满足监控场景的需求,这里先介绍两个概念:

Jan 3, 2023
Fast and simple key/value store written using Go's standard library
Fast and simple key/value store written using Go's standard library

Table of Contents Description Usage Cookbook Disadvantages Motivation Benchmarks Test 1 Test 4 Description Package pudge is a fast and simple key/valu

Nov 17, 2022
Multi producer and multi-reader lockless ring buffer in go using generics from the go 1.18beta release

LocklessGenericRingBuffer This is an implementation of a multi producer, multi r

Dec 25, 2022
golang bigcache with clustering as a library.

clusteredBigCache This is a library based on bigcache with some modifications to support clustering and individual item expiration Bigcache is an exce

Sep 26, 2022
moss - a simple, fast, ordered, persistable, key-val storage library for golang

moss moss provides a simple, fast, persistable, ordered key-val collection implementation as a 100% golang library. moss stands for "memory-oriented s

Dec 18, 2022
A tiny Golang JSON database

Scribble A tiny JSON database in Golang Installation Install using go get github.com/nanobox-io/golang-scribble. Usage // a new scribble driver, provi

Dec 31, 2022