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 Package1 | |
/* The interface is exported, so publically available */ | |
type MyStructsInterface interface { | |
SomeInterfaceMethod() int | |
} | |
/* Private struct */ | |
type myStruct struct { | |
num int |
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 Package2 | |
type SomeService struct { } | |
func (*SomeService) DoSomething(obj myStruct) { /* WONT WORK!!*/ } |
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
/* Yep, now it's private because of the lower-cased 'm' */ | |
type myStruct struct { | |
num int | |
} | |
func NewMyStruct() *myStruct { | |
return &myStruct{num: 42} | |
} |
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
type MyStruct struct { | |
dep *ADependency | |
} | |
func (m *MyStruct) DoSomethingWithDep() { | |
m.dep.DoSomething() | |
} | |
type ADependency struct { | |
num int |
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
myStruct := MyStruct{} |
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
type MyStruct struct { } | |
func NewMyStruct() MyStruct { | |
return MyStruct{dep: ADependency{}} | |
} | |
type ADependency struct { } | |
myStruct := NewMyStruct() // We get back a valid struct |
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
#!/bin/bash | |
fileid="$1" | |
filename="$2" | |
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null | |
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o "${filename}" | |
# USAGE: sh gdrive.sh "<FILE ID (FROM URL) GOES HERE>" "<FILE NAME (FROM TOP LEFT OF GDRIVE PAGE) GOES HERE>" | |
# Example: sh gdrive.sh "1zJ_dLqrJwU5QYHSJDKFLnDC3LSJD" "The Name Of My File.zip" |
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
struct JsonDownloader | |
{ | |
public func downloadContentsOfUrl(_ url: URL) -> Promise<String> { | |
return Promise { resolve, reject in | |
let jsonData = try! Data(contentsOf: url) | |
let jsonData = try! JSONSerialization.jsonObject(with: response, options: []) as! [String: Any] | |
return resolve(url: jsonData['image_url']) | |
} |
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
DispatchQueue.global(qos: .background).async { | |
let jsonDownloader: JsonDownloader = JsonDownloader() | |
let imageDownloader: ImageDownloader = ImageDownloader() | |
let json: [String: AnyObject] = jsonDownloader.downloadContentsOfUrl("ourUrl.com") | |
let image: UIImage = imageDownloader.downloadImage(URL(string: json["image_url"])) | |
DispatchQueue.main.async { | |
// -- SNIP -- Add image to UIImageView and add a subview in UIView |
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
class ViewController: UIViewController | |
{ | |
override func viewDidLoad() | |
{ | |
super.viewDidLoad() | |
async { | |
let jsonDownloader: JsonDownloader = JsonDownloader() | |
let imageDownloader: ImageDownloader = ImageDownloader() | |