본문 바로가기

전체 글343

[Go] Package bufio Package bufio implements buffered I/O. Methods type Scanner 더보기 NewScanner NewScanner returns a new Scanner to read from r. func NewScanner (r io.Reader) *Scanner Err Err returns the first non-EOF error that was encountered by the Scanner. func (s *Scanner) Err() error Scan Scan advances the Scanner to the next token, which will then be available through the Bytes or Text method. It returns fals.. 2020. 10. 31.
[Go] Package errors Package errors implements functions to manipulate errors. Methods New New returns an error that formats as the given text. Each call to New returns a distinct error value even if the text is identical. func New(text string) error Usages package main import ( "errors" "log" ) func main() { err := errors.New("error: my error") if err != nil { log.Fatal(err) } } // error: my error 2020. 10. 29.
[Go] Package math Package math Package math provides basic constants and mathematical functions. Package rand Package rand implements pseudo-random number generators. Methods Seed Seed uses the provided seed value to initialize the default Source to a deterministic state. Seed values that have the same remainder when divided by 2^31 - 1 generate the same pseudo-random sequence. Seed, unlike the Rand.Seed method, .. 2020. 10. 27.
[Go] Package strconv Package strconv implements conversions to and from string representations of basic data types. Methods Atoi Atoi equivalent to ParseInt(s, 10, 0), converted to type int. func Atoi(s string) (int, error) Itoa Itoa is equivalent to FormatInt. func Itoa(i int) string ParseBool, ParseUInt, ParseInt, ParseFloat ParseBool, ParseUInt, ParseInt, and ParseFloat convert strings to values. func ParseBool(s.. 2020. 10. 26.
[Go] Package strings Package strings implements simple functions to manipulate UTF-8 encoded strings. Methods TrimSpace TrimSpace returns a slice of the string, with all leading and trailing white space removed, as defined by Unicode. func TrimSpace(s string) string Usages package main import ( "fmt" "strings" ) func main() { greeting := "\n Hi, nice to meet you \t\n" fmt.Println(strings.TrimSpace(greeting)) // Hi, .. 2020. 10. 26.
[Go] Basic Go is a statically typed language. Let me show you a very default Go program. package main import "fmt" func main() { fmt.Println("Hello, Go!") } The first line declares which package to use. We run the program directly in the terminal, so the main package is needed. The next line imports fmt package. The example program prints the message through Println function in the fmt package. Then finall.. 2020. 10. 26.
[TypeScript] Type Inference TypeScript provides the type inference. const b = true; console.log(typeof b); // boolean const n = 3; console.log(typeof n); // number const f = 3.14; console.log(typeof f); // number const s = 'Hello'; console.log(typeof s); // string Best Common Type When a type inference is made from several expressions, the types of those expressions are used to calculate a 'best common type'. When no best .. 2020. 10. 25.
[TypeScript] Decorators Decorators are a stage 2 proposal for JavaScript and are available as an experimental feature of TypeScript. So you should set the feature in your tsconfig.js. { "compilerOptions": { "target": "es5" "experimentalDecorators": true ... } } A decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. Decorators use the form @exp.. 2020. 10. 24.
[TypeScript] Iterators and Generators Iterator is a behavioral design pattern that allows sequential traversal through a complex data structure without exposing its internal details. Generator is a lazy iterator. Iterables An object is deemed iterable if it has an implementation for the Symbol.iterator property. Some built-in types like Array, Map, Set, String, Int32Array, Uint32Array, etc. have their Symbol.iterator property alread.. 2020. 10. 23.