A summary of the official Microsoft C# coding conventions, based on Microsoft’s documentation.
- PascalCase for class, property, method, and namespace names
public class MyExampleClass { }
| package templating | |
| import ( | |
| "encoding/base64" | |
| "net/http" | |
| "time" | |
| "reload-helper/internal/global" | |
| ) |
| func loadEnvVars(filename string) { | |
| file, err := os.Open(filename) | |
| if err != nil { | |
| log.Fatalf("failed to open env file: %v", err) | |
| } | |
| defer file.Close() | |
| scanner := bufio.NewScanner(file) | |
| for scanner.Scan() { | |
| line := strings.TrimSpace(scanner.Text()) |
A summary of the official Microsoft C# coding conventions, based on Microsoft’s documentation.
public class MyExampleClass { }| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "log" | |
| "net/url" | |
| "strings" | |
| ) |
Please observe the difference in speed when calling resp.Body.Close().
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| "strconv" | |
| ) | |
| var ( | |
| paragraphs = []string{ |
| using Org.BouncyCastle.Crypto; | |
| using Org.BouncyCastle.Crypto.Encodings; | |
| using Org.BouncyCastle.Crypto.Engines; | |
| using Org.BouncyCastle.Crypto.Generators; | |
| using Org.BouncyCastle.OpenSsl; | |
| using Org.BouncyCastle.Security; | |
| using System.Text; | |
| namespace RSATest |
| [Unit] | |
| Description=CertMaker Bot (to cover your cert needs) | |
| After=network.target | |
| [Service] | |
| Type=simple | |
| ExecStart=/home/certmaker-bot/bin/certmaker-bot | |
| WorkingDirectory=/home/certmaker-bot/bin | |
| User=certmaker-bot | |
| Group=certmaker-bot |
| $sourcecode = ".\main.go" | |
| $target = "build\binary-name" | |
| # Windows, 64-bit | |
| $env:GOOS = 'windows'; $env:GOARCH = 'amd64'; go build -o "$($target)-win64.exe" -ldflags "-s -w" $sourcecode | |
| # Linux, 64-bit | |
| $env:GOOS = 'linux'; $env:GOARCH = 'amd64'; go build -o "$($target)-linux64" -ldflags "-s -w" $sourcecode | |
| # Raspberry Pi | |
| $env:GOOS = 'linux'; $env:GOARCH = 'arm'; $env:GOARM=5; go build -o "$($target)-raspi32" -ldflags "-s -w" $sourcecode | |
| # macOS | |
| $env:GOOS = 'darwin'; $env:GOARCH = 'amd64'; go build -o "$($target)-macos64" -ldflags "-s -w" $sourcecode |