Skip to content

Instantly share code, notes, and snippets.

View feicun's full-sized avatar

Haoming Zhang feicun

View GitHub Profile

VIM-GO

Plugin https://github.com/fatih/vim-go
Tutorial https://github.com/fatih/vim-go-tutorial
Vimrc https://github.com/fatih/dotfiles/blob/master/vimrc

Run

Commands

  • File :GoRun %
  • Package :GoRun
  • Debug :GoDebugStart

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@feicun
feicun / localrc
Created November 12, 2015 01:17
localrc config file for DevStack installation
# Misc
DATABASE_PASSWORD=123456
ADMIN_PASSWORD=123456
SERVICE_PASSWORD=123456
SERVICE_TOKEN=123456
RABBIT_PASSWORD=123456
# Reclone each time
#RECLONE=True
@feicun
feicun / pyscp.py
Created August 7, 2014 00:42
Transfer file or folder to remote server use rsync protocal
#!/usr/bin/env python
# Transfer file or folder to remote server use rsync protocal
# If you get a prompt says "Is a directory"
# Please double check your server list file, and make sure
# the directories existing on corresponding server
import os
import sys
@feicun
feicun / Preferences.sublime-settings
Last active October 31, 2016 18:54
Sublime text 3 configuration
{
"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night-Eighties.tmTheme",
"ignored_packages":
[
"Vintage"
],
"theme": "Soda Dark 3.sublime-theme",
"translate_tabs_to_spaces": true,
"word_wrap": true,
"highlight_line": true,
@feicun
feicun / sublime-text-3.sh
Last active December 29, 2015 12:39
Change the default install path to ~/opt. 'ln' the program to /usr/bin (last sentence), so you can run the program in terminal by type "sublime-text". Create the desktop shortcut correctly.
#!/usr/bin/env bash
# Usage: {script} TARGET BUILD
#
# TARGET Default target is "/opt".
# BUILD If not defined tries to get the build into the Sublime Text 3 website.
#
set -e
declare URL