package
0.0.0-20240221030254-46f66de34eb6
Repository: https://github.com/jeffotoni/goexample.git
Documentation: pkg.go.dev
# README
Pattern Singleton
Sempre me deparo com necessidade de implementar o Pattern Singleton em meus projetos, mas em Golang existem algumas particularidades que temos que tomar cuidado. Neste artigo, vou apresentar duas formas de implementar o Singleton usando Golang, a forma “Not Thread Safe” e a forma “Thread Safe”. O objetivo é apresentar de forma prática e técnica as formas de implementação e quando temos que implementar o patterns singleton.
/*
* Example DriverPg Go
* @package main
* @author @jeffotoni
* @size 10/09/2018
*/
package main
import (
"fmt"
"time"
)
type DriverPg struct {
conn string
}
// variavel Global
var instance *DriverPg
// fazendo uma chamada do
// metodo, antes de qualquer
// chamada
var instanceNew = *Connect()
...
# Functions
funcao retornando o ponteiro de nossa struct.
funcao retornando o ponteiro de nossa struct.
funcao retornando o ponteiro de nossa struct.
funcao retornando o ponteiro de nossa struct.
funcao retornando o ponteiro de nossa struct.
funcao retornando o ponteiro de nossa struct.
No description provided by the author
No description provided by the author
# Variables
<-- Global objeto Connect.
variavel extern.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
driver.
driver.
driver.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Struct singleton.
Struct singleton.
Struct singleton.