Outils pour utilisateurs

Outils du site


blog

Go lang - regex

// Source - https://stackoverflow.com/a/41551456
// Posted by Mr_Pink, modified by community. See post 'Timeline' for change history
// Retrieved 2026-05-14, License - CC BY-SA 3.0
 
func IsMatchingRegex(s string, regex string) bool {
    return regexp.MustCompile(regex).MatchString(s)
}

FIXME

2026/05/14 20:11 · Jean-Baptiste

Go lang - goroutines

Pb sortie de main avant terminaisons des goroutines - Attendre la fin de toutes les goroutines avant de terminer le programme (la fonction main)

Afficher les résultats des goroutine de la plus rapide à la plus longue

Voir :

        ch1 := make(chan int)
        ch2 := make(chan int)
        go evenSum(1, 10, ch1)
        go squareSum(1, 10, ch2)
        for range 2 {
                select {
                case r1 := <-ch1:
                        fmt.Println(r1)
                case r2 := <-ch2:
                        fmt.Println(r2)
                }
        }

FIXME

2026/05/06 22:58 · Jean-Baptiste

Notes code dev - qualité de code - bonnes pratiques - sécu

Voir :

Points:

  • Testing
  • Negative testing (tests that should cause failures)
  • Detect and check unreachable code, e.g., via warning flags (static analysis)
  • Forbid misleading indentation (static analysis)
  • Detect duplicate lines in source code (static analysis)
  • Make access failure the default (static analysis)
  • Make your methods do only one thing
  • Use readable, descriptive variable names

4 tools:

  • ASan (Address Sanitizer)
  • MSan (Memory Sanitizer)
  • UBSan (Undefined Behaviour Sanitizer)
  • Valgrind
  • fuzzing

Source : https://www.cl.cam.ac.uk/~nk480/C1819/lecture5.pdf

Autres

  • AddressSanitizer (detects addressability issues) and LeakSanitizer (detects memory leaks)
  • ThreadSanitizer (detects data races and deadlocks) for C++ and Go
  • MemorySanitizer (detects use of uninitialized memory)
  • HWASAN, or Hardware-assisted AddressSanitizer, a newer variant of AddressSanitizer that consumes much less memory UBSan, or UndefinedBehaviorSanitizer

Source : https://github.com/google/sanitizers

FIXME

2026/05/04 20:51 · Jean-Baptiste

Go lang - GUI

Par nature Go n'est pas orienté utilisateur.

L'interface graphique “naturelle” à Go est le Web (WebUI)

Cependant il est possible d'utiliser :

  • Tk9 https://pkg.go.dev/modernc.org/tk9.0 pour des applis simple et portable CGo-free il est vraiment natif Go et crossplatform
  • Qt avec https://github.com/mappu/miqt Qt est la référence
  • Wails projet prometteur, mais pas compatible pour les anciennes versions. nécessite Node (Svelte, React, Vue, Preact, Lit, Vanilla)
  • Flutter : Pour Android

Qt - miqt

package main
 
import (
        "fmt"
        "os"
 
        "github.com/mappu/miqt/qt"
)
 
func main() {
 
        qt.NewQApplication(os.Args)
 
        btn := qt.NewQPushButton3("Hello world!")
        btn.SetFixedWidth(320)
 
        var counter int = 0
 
        btn.OnPressed(func() {
                counter++
                btn.SetText(fmt.Sprintf("You have clicked the button %d time(s)", counter))
        })
 
        btn.Show()
 
        qt.QApplication_Exec()
 
        fmt.Println("OK!")
}

FIXME

2026/05/03 18:03 · Jean-Baptiste
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki