Skip to content

Instantly share code, notes, and snippets.

Non-Local File Systems Should Be Supported

TL;DR

Files are all over the Internet, and Go should provide a reasonable abstraction in its stdlib to handle this.

Problem

Files are everywhere. Local disk is the obvious place. But they're also in storage buckets like Google Cloud Storage and Amazon S3. They're in code repositories like GitHub and Google Source. They're in personal storage like Dropbox and Evernote. They're on other machines or filesystems on corporate Intranets. Tests which write to disk are much less error-prone if they write to volatile memory, such as a RAMFS.

Go 1's os package provides an os.File struct. The implicit assumption is that local disk storage is the only thing the stdlib should care about, and that external packages should provide access to these other sources. In 2007, this would have been a reasonable approach. In 2017, files are increasingly unlikely to be local.

java_toolchain(
name = "java8",
encoding = "UTF-8",
source_version = "8",
target_version = "8",
misc = [
"-extra_checks:on",
],
)
import Data.Char
import Data.String.Utils
import Data.Maybe
import qualified Data.Map as M
import System.Environment
import Control.Parallel
import Control.Parallel.Strategies
import Control.Monad
type WordCount = M.Map String Int
protected function targetButton_dragDropHandler(event:DragEvent):void
{
var draggedButton:Button = event.dragInitiator as Button;
var droppedOnButton:IVisualElement = event.currentTarget as IVisualElement;
var newButton:Button = new Button();
var parent:Group = droppedOnButton.parent as Group;
// Set up the new button
newButton.label(draggedButton.label);
newButton.color(draggedButton.color);
@cflewis
cflewis / json.go
Created September 24, 2012 21:26
Parse JSON example
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
)
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
)
@cflewis
cflewis / gist:1244092
Created September 27, 2011 01:49
Docgen, a silly personal script to handle pre and post processing of Pandoc files
#! /usr/bin/env python
import re
import subprocess
import tempfile
import sys
import os
class Processor(object):
def __init__(self):
pass
package com.cflewis.lyss.kitty_server
import akka.actor.Actor
import akka.actor.Actor._
import akka.config.Supervision._
case class Cat(name: String, color: String, description: String)
case class OrderCat(name: String, color: String, description: String)
case class ReturnCat(cat: Cat)
case class CloseShop()
class StarcraftResourceGame extends EgyptModel {
val name = "Starcraft Resource Game"
def get_crystal = {
require(crystals > 0)
crystals--
}
def get_gas = {
require(gas > 0)
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*