Normally, it is sufficient to grab the Go MSI installer from the website in order to set up the toolchain. However, some packages that provide Go wrappers for C libraries rely on cgo tool, which in turn, needs the GCC toolchain in order to build the glue code. Also, 3rd-party dependencies are usually hosted on services like GitHub, thus Git is also needed. This mini-guide illustrates how to setup a convenient development environment on Windows using MSYS2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 解析嵌入类型的字段 | |
def parse_one_embed(self, start: int) -> int: | |
all_range = [] | |
gap_fields = [] | |
end = start | |
last_elem_prefix = '' | |
for i in range(start, len(self.fields)): | |
field = self.fields[i] | |
prefix, idx = helper.parse_array_name_index(field.name) | |
if prefix != '' and idx == 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestAABB(t *testing.T) { | |
t.Logf("size of map = %d", unsafe.Sizeof(map[int]int{})) | |
var a any = gsdb.DbUser{} | |
var typ = reflectutil.TypeOf(a) | |
var n = (int(typ.PtrBytes)/8 + 7) / 8 | |
var sb strings.Builder | |
var ones = 0 | |
for i := 0; i < n; i++ { | |
var ptr = unsafe.Add(unsafe.Pointer(typ.GCData), i) | |
var v = *(*uint8)(ptr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xlrd | |
import openpyxl | |
# 读取指定xls文件的某一个sheet | |
def read_workbook_sheet_to_rows(filename: str, sheet_name: str): | |
print('load workbook', filename) | |
if filename.endswith('.xls'): | |
return __xlrd_read_workbook_sheet_to_rows(filename, sheet_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"path/filepath" | |
) | |
var print = fmt.Println |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Validate if a given string is numeric. | |
// https://leetcode.com/problems/valid-number/ | |
bool isNumber(const char* s) | |
{ | |
if (s == NULL) | |
{ | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* DO NOT EDIT THIS FILE - it is machine generated */ | |
#include <jni.h> | |
/* Header for class tutorial_myfirstapp_MainActivity */ | |
#ifndef _Included_tutorial_myfirstapp_MainActivity | |
#define _Included_tutorial_myfirstapp_MainActivity | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local socket = require 'socket' | |
local coroutine = coroutine | |
local threads = {} | |
local function receive(connection) | |
connection:settimeout(0) | |
local s, status, partial = connection:receive(2^10) | |
if status == 'timeout' then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local coroutine = coroutine | |
local function receive(p) | |
local s, value = coroutine.resume(p) | |
return value | |
end | |
local function send(x) | |
coroutine.yield(x) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- map(table, function) | |
-- e.g: map({1,2,3}, function(a) return a*2 end) -> {2,4,6} | |
function map(tbl, func) | |
local newtbl = {} | |
for i,v in pairs(tbl) do | |
newtbl[i] = func(v) | |
end | |
return newtbl | |
end |
NewerOlder