Let's imagine a very simple table
CREATE TABLE people {
id bigserial,
name character varying
}
// Use Case: | |
// | |
// Say you have a bunch of decoupled components which access the same set of databases. | |
// Since database/sql does connection pooling it makes sense for the components to share instances of *sql.DB | |
// This package lets you do that with minimal code changes. | |
package dbmanager | |
import ( | |
"database/sql" | |
"time" |
package tests | |
import ( | |
"testing" | |
) | |
type S struct { | |
t *testing.T | |
} |
package fakeresponse | |
import ( | |
"testing" | |
"net/http" | |
) | |
type FakeResponse struct { | |
t *testing.T | |
headers http.Header |
#!/usr/bin/python | |
# | |
# Copyright (c) 2012 Dave Pifke. | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to | |
# deal in the Software without restriction, including without limitation the | |
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
# sell copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
def add_cors_headers(response): | |
response.headers['Access-Control-Allow-Origin'] = '*' | |
if request.method == 'OPTIONS': | |
response.headers['Access-Control-Allow-Methods'] = 'DELETE, GET, POST, PUT' | |
headers = request.headers.get('Access-Control-Request-Headers') | |
if headers: | |
response.headers['Access-Control-Allow-Headers'] = headers | |
return response | |
app.after_request(add_cors_headers) |
#!/usr/bin/env python3 | |
import requests | |
from flask import * | |
import random | |
from apscheduler.schedulers.background import BackgroundScheduler | |
app = Flask(__name__) | |
scheduler = BackgroundScheduler() | |
url = "https://reddit.com/r/gonewild/comments.json?limit=200" |
import com.squareup.moshi.Json | |
import com.squareup.moshi.KotlinJsonAdapterFactory | |
import com.squareup.moshi.Moshi | |
import com.squareup.moshi.Rfc3339DateJsonAdapter | |
import java.util.Date | |
val json = """ | |
{ | |
"url": "https://api.github.com/repos/square/okio/issues/156", | |
"id": 91393390, |
This list has the goal of helping developers interested in contributing to the Go language but are unsure of where to start. This was not generated manually so some functions and methods here may not require examples (maybe because they are too simple, e.g .String()) and some of these may only make sense in a package level example (which are not considered for this list yet). Use your best judgment and check the documentation before you open up a CL to add an example.
You should also search in gerrit for open CLs that are already adding examples.
I will try to keep this list as up to date as possible. If you find any mistakes, please comment below and I will try to fix it.