singleton

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package singleton implements the Singleton design pattern. The example demonstrates the usability of the Notepad struct, that can be used in different places in the application through the GetTodoNotepad singleton creating method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run()

Types

type Notepad

type Notepad struct {
	// contains filtered or unexported fields
}

Notepad represents the object, that encapsulates the logic of adding and printing the notes into it

func GetTodoNotepad

func GetTodoNotepad() *Notepad

GetTodoNotepad is the Singleton constructor for the Todo list notepad, that can be reused in different places of the application

func (*Notepad) AddNote

func (n *Notepad) AddNote(note string) *Notepad

AddNote is the part of the public interface for the notes mutations

func (*Notepad) String

func (n *Notepad) String() string

String implement Stringer interface for the notepad to be able to work with the elements in print ready format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL