This file contains hidden or 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
// config | |
c, err := mylib.New(&mylib.Config{ | |
Username: "uname", | |
Password: "pw", | |
}) | |
// methods | |
c, err := mylib.New("required") | |
if err !=nil{ | |
// ... |
This file contains hidden or 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 mylib | |
import "net/http" | |
// New create a new Instance of mylib | |
func New(someAlwaysRequiredValue string) (*Builder, error) { | |
return &Builder{ | |
// some nice sane defaults if necessary | |
}, nil | |
} |
This file contains hidden or 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 mylib | |
import "net/http" | |
// New create a new Instance of mylib | |
func New(someAlwaysRequiredValue string, options ...func(*Instance) error) (*Instance, error) { | |
return &Instance{ | |
client: new(http.Client), // default no auth client | |
}, nil | |
} |
This file contains hidden or 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 mylib | |
import "net/http" | |
// New create a new Instance of mylib | |
func New(someAlwaysRequiredValue string) (*Instance, error) { | |
return &Instance{ | |
client: new(http.Client), // default no auth client | |
}, nil | |
} |
This file contains hidden or 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 mylib | |
import "net/http" | |
// Config contains all library configuration data | |
type Config struct { | |
Username string | |
Password string | |
} |
This file contains hidden or 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 lib | |
import ( | |
"testing" | |
"os" | |
"github.com/stretchr/testify/require" | |
) |
This file contains hidden or 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 lib | |
import ( | |
"errors" | |
"strings" | |
) | |
// DoThings ... | |
func DoThings(s string) error { | |
if strings.Contains(s, "thing") { |
This file contains hidden or 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
extern crate image; | |
extern crate num_cpus; | |
use std::fs::File; | |
use std::thread; | |
use std::sync::{Arc, Mutex}; | |
use std::sync::mpsc::channel; | |
use std::cell::RefCell; | |
const WIDTH: u32 = 2048; |
This file contains hidden or 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
extern crate download; | |
use std::{io, fs}; | |
use std::io::{Read, Write}; | |
#[test] | |
fn test_open(){ | |
let mut file = download::open("http://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz").unwrap(); | |
println!("{:?}",file); |
This file contains hidden or 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
extern crate hyper; | |
extern crate crypto; | |
use std::{env, result}; | |
use std::path::Path; | |
use std::{io, fs}; | |
use std::io::{Read, Write, Seek, SeekFrom}; | |
use hyper::Client; | |
use hyper::status::StatusCode; |
NewerOlder