Skip to content

Instantly share code, notes, and snippets.

@GimmyHchs
GimmyHchs / tclient.go
Created March 18, 2020 02:27
[Go Client Mock]
package tclient
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
var unexpectRoundTrip = func(req *http.Request) *http.Response {
@GimmyHchs
GimmyHchs / float_precision_round.go
Last active August 8, 2019 10:31
[Golang Float Tricks] golang float tricks #go
package main
import (
"fmt"
"math"
)
func main() {
var a, b, c, d float64
@GimmyHchs
GimmyHchs / slice_tricks.md
Last active February 8, 2024 22:23
[Go SliceTricks] golang slice tricks #go

Since the introduction of the append built-in, most of the functionality of the container/vector package, which was removed in Go 1, can be replicated using append and copy.

Here are the vector methods and their slice-manipulation analogues:

AppendVector

a = append(a, b...)

Copy

@GimmyHchs
GimmyHchs / newmac.md
Last active July 1, 2019 03:00
New macbook
@GimmyHchs
GimmyHchs / logout.sh
Last active April 16, 2019 08:26
Redis bulk delete
redis-cli -p 6380 --scan --pattern "AUTH:*" | xargs redis-cli -p 6380 del
@GimmyHchs
GimmyHchs / reinstall-go-and-spacemacs.md
Last active January 11, 2020 04:24
Reinstall go spacemacs
@GimmyHchs
GimmyHchs / AdjustmentOrderService.php
Last active July 2, 2019 05:51
Laravel ORM gists
<?php
/**
* 取得含有費用調整order集合.
*
* @param string $orderNo
*
* @return AdjustmentOrderCollection
*/
public function fetchOrders($orderNo = null)
{