diff --git a/examples.txt b/examples.txt index 1ad6eca..58af207 100644 --- a/examples.txt +++ b/examples.txt @@ -1,74 +1,74 @@ -Hello World -Типы данных (Values) -Переменные (Variables) -Константы (Constants) -Цикл For -If/Else -Switch -Массивы (Arrays) -Срезы (Slices) -Карты (Maps) -Ряд (Range) -Функции (Functions) -Функции с множественным возвратом (Multiple Return Values) -Функции с переменным числом аргументов (Variadic Functions) -Замыкания (Closures) -Рекурсия (Recursion) -Указатели (Pointers) -Структуры (Structs) -Методы (Methods) -Интерфейсы (Interfaces) -Ошибки (Errors) -Горутины (Goroutines) -Каналы (Channels) -Буферизированный канал (Channel Buffering) -Синхронизация канала (Channel Synchronization) -Направления канала (Channel Directions) -Select -Тайм-ауты (Timeouts) -Неблокируемые операции в каналах (Non-Blocking Channel Operations) -Закрытие каналов (Closing Channels) -Перебор значений из каналов (Range over Channels) -Таймеры (Timers) -Тикеры (повторения) (Tickers) -Пулы воркеров (Worker Pools) -WaitGroups -Ограничение скорости (Rate Limiting) -Атомарные счетчики (Atomic Counters) -Мьютексы (Mutexes) -Управление состоянием горутин (Stateful Goroutines) -Сортировка (Sorting) -Сортировка через функции (Sorting by Functions) -Panic -Defer -Функции коллекции (Collection Functions) -Строковые функции (String Functions) -Форматирование строк (String Formatting) -Регулярные выражения (Regular Expressions) -JSON -XML -Время (Time) -Epoch -Форматирование времени (Time Formatting / Parsing) -Случайные числа (Random Numbers) -Парсинг чисел (Number Parsing) -Парсинг URL (URL Parsing) -Хеш SHA1 (SHA1 Hashes) -Кодирование Base64 (Base64 Encoding) -Чтение файлов (Reading Files) -Запись файлов (Writing Files) -Строковые фильтры (Line Filters) -Пути к файлам (File Paths) -Директории (Directories) -Временные файлы и директории (Temporary Files and Directories) -Тестирование (Testing) -Аргументы командной строки (Command-Line Arguments) -Флаги командной строки (Command-Line Flags) -Подкоманды командной строки (Command-Line Subcommands) -Переменные среды (Environment Variables) -HTTP клиенты (HTTP Clients) -HTTP серверы (HTTP Servers) -Порождающие процессы (Spawning Processes) -Исполняющие процессы (Exec'ing Processes) -Сигналы (Signals) -Выход (Exit) +Hello World|Hello World +Типы данных (Values)|Values +Переменные (Variables)|Variables +Константы (Constants)|Constants +Цикл For|For +If/Else|If/Else +Switch|Switch +Массивы (Arrays)|Arrays +Срезы (Slices)|Slices +Карты (Maps)|Maps +Ряд (Range)|Range +Функции (Functions)|Functions +Функции с множественным возвратом (Multiple Return Values)|Multiple Return Values +Функции с переменным числом аргументов (Variadic Functions)|Variadic Functions +Замыкания (Closures)|Closures +Рекурсия (Recursion)|Recursion +Указатели (Pointers)|Pointers +Структуры (Structs)|Structs +Методы (Methods)|Methods +Интерфейсы (Interfaces)|Interfaces +Ошибки (Errors)|Errors +Горутины (Goroutines)|Goroutines +Каналы (Channels)|Channels +Буферизированный канал (Channel Buffering)|Channel Buffering +Синхронизация канала (Channel Synchronization)|Channel Synchronization +Направления канала (Channel Directions)|Channel Directions +Select|Select +Тайм-ауты (Timeouts)|Timeouts +Неблокируемые операции в каналах (Non-Blocking Channel Operations)|Non-Blocking Channel Operations +Закрытие каналов (Closing Channels)|Closing Channels +Перебор значений из каналов (Range over Channels)|Range over Channels +Таймеры (Timers)|Timers +Тикеры (повторения) (Tickers)|Tickers +Пулы воркеров (Worker Pools)|Worker Pools +WaitGroups|WaitGroups +Ограничение скорости (Rate Limiting)|Rate Limiting +Атомарные счетчики (Atomic Counters)|Atomic Counters +Мьютексы (Mutexes)|Mutexes +Управление состоянием горутин (Stateful Goroutines)|Stateful Goroutines +Сортировка (Sorting)|Sorting +Сортировка через функции (Sorting by Functions)|Sorting by Functions +Panic|Panic +Defer|Defer +Функции коллекции (Collection Functions)|Collection Functions +Строковые функции (String Functions)|String Functions +Форматирование строк (String Formatting)|String Formatting +Регулярные выражения (Regular Expressions)|Regular Expressions +JSON|JSON +XML|XML +Время (Time)|Time +Epoch|Epoch +Форматирование времени (Time Formatting / Parsing)|Time Formatting / Parsing +Случайные числа (Random Numbers)|Random Numbers +Парсинг чисел (Number Parsing)|Number Parsing +Парсинг URL (URL Parsing)|URL Parsing +Хеш SHA1 (SHA1 Hashes)|SHA1 Hashes +Кодирование Base64 (Base64 Encoding)|Base64 Encoding +Чтение файлов (Reading Files)|Reading Files +Запись файлов (Writing Files)|Writing Files +Строковые фильтры (Line Filters)|Line Filters +Пути к файлам (File Paths)|File Paths +Директории (Directories)|Directories +Временные файлы и директории (Temporary Files and Directories)|Temporary Files and Directories +Тестирование (Testing)|Testing +Аргументы командной строки (Command-Line Arguments)|Command-Line Arguments +Флаги командной строки (Command-Line Flags)|Command-Line Flags +Подкоманды командной строки (Command-Line Subcommands)|Command-Line Subcommands +Переменные среды (Environment Variables)|Environment Variables +HTTP клиенты (HTTP Clients)|HTTP Clients +HTTP серверы (HTTP Servers)|HTTP Servers +Порождающие процессы (Spawning Processes)|Spawning Processes +Исполняющие процессы (Exec'ing Processes)|Exec'ing Processes +Сигналы (Signals)|Signals +Выход (Exit)|Exit diff --git a/examples/arrays/arrays.hash b/examples/arrays/arrays.hash index 8ab57f4..ad69e96 100644 --- a/examples/arrays/arrays.hash +++ b/examples/arrays/arrays.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +cbd7ae7158cdb62fbd0f5a21c1f89a9a43369900 +CiZ6oDF6A_l diff --git a/examples/atomic-counters/atomic-counters.hash b/examples/atomic-counters/atomic-counters.hash index 8ab57f4..d8d3864 100644 --- a/examples/atomic-counters/atomic-counters.hash +++ b/examples/atomic-counters/atomic-counters.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +e1b3a73458ef10d4cfe093766d05503ed7706544 +aEOYD0chCYy diff --git a/examples/base64-encoding/base64-encoding.hash b/examples/base64-encoding/base64-encoding.hash index 717ff3f..b5f4766 100644 --- a/examples/base64-encoding/base64-encoding.hash +++ b/examples/base64-encoding/base64-encoding.hash @@ -1,2 +1,2 @@ -e0148b9b4acb01e849b8f678cba03f549d250c44 -V3oV1bvh94k +0a1abdfdd647b24082d46fd54645bc597fb86b83 +3E068RAuW3p diff --git a/examples/channel-buffering/channel-buffering.hash b/examples/channel-buffering/channel-buffering.hash index 8ab57f4..b8c3cbb 100644 --- a/examples/channel-buffering/channel-buffering.hash +++ b/examples/channel-buffering/channel-buffering.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +4d4cf7b115f26c12d7e188a2d25c66e64f34edfe +HNVSsVpnHXN diff --git a/examples/channel-directions/channel-directions.hash b/examples/channel-directions/channel-directions.hash index 8ab57f4..700e311 100644 --- a/examples/channel-directions/channel-directions.hash +++ b/examples/channel-directions/channel-directions.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +a0904bf943d61e4d220f29ef3a0e6f1368657e78 +uEeOmen99CF diff --git a/examples/channel-synchronization/channel-synchronization.hash b/examples/channel-synchronization/channel-synchronization.hash index 8ab57f4..16fea5e 100644 --- a/examples/channel-synchronization/channel-synchronization.hash +++ b/examples/channel-synchronization/channel-synchronization.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +29e4099160217bd2817aef8546927056b9ea4b12 +3NHqwE7Bwjz diff --git a/examples/channels/channels.hash b/examples/channels/channels.hash index 8ab57f4..eac8a35 100644 --- a/examples/channels/channels.hash +++ b/examples/channels/channels.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +92a2a89118f08e7ac1fcf82567c14a31e6a2fabe +jHsjIHrpHXV diff --git a/examples/closing-channels/closing-channels.hash b/examples/closing-channels/closing-channels.hash index 8ab57f4..16da6f6 100644 --- a/examples/closing-channels/closing-channels.hash +++ b/examples/closing-channels/closing-channels.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +67493a491669c559ceac851a959828a00ceb89eb +V8RCD4w9KY- diff --git a/examples/closures/closures.hash b/examples/closures/closures.hash index 8ab57f4..104a80b 100644 --- a/examples/closures/closures.hash +++ b/examples/closures/closures.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +5a274ea5c01af8573ce5c6382f41189446a8be09 +J2PladF_bU9 diff --git a/examples/collection-functions/collection-functions.hash b/examples/collection-functions/collection-functions.hash index 8ab57f4..49e6fd6 100644 --- a/examples/collection-functions/collection-functions.hash +++ b/examples/collection-functions/collection-functions.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +5e8a32a022ffb4f746bbdf101face52ca008aeba +urAoHQtRHro diff --git a/examples/command-line-arguments/command-line-arguments.hash b/examples/command-line-arguments/command-line-arguments.hash index 8ab57f4..b81990d 100644 --- a/examples/command-line-arguments/command-line-arguments.hash +++ b/examples/command-line-arguments/command-line-arguments.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +375f50de2467743174f0d60d0635a3198e031094 +wSDrVn9TIK5 diff --git a/examples/command-line-flags/command-line-flags.hash b/examples/command-line-flags/command-line-flags.hash index 8ab57f4..2262d76 100644 --- a/examples/command-line-flags/command-line-flags.hash +++ b/examples/command-line-flags/command-line-flags.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +e316c57acf4cc993f182f2d341a608a1eac4a551 +_r_-ZzDzQUH diff --git a/examples/command-line-subcommands/command-line-subcommands.hash b/examples/command-line-subcommands/command-line-subcommands.hash index 8ab57f4..f695b3c 100644 --- a/examples/command-line-subcommands/command-line-subcommands.hash +++ b/examples/command-line-subcommands/command-line-subcommands.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +7320b5803ad9875733c4ca9644600ae8a55009d8 +sr1FH0P_2Te diff --git a/examples/constants/constants.hash b/examples/constants/constants.hash index 8ab57f4..9cb2151 100644 --- a/examples/constants/constants.hash +++ b/examples/constants/constants.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +31b56e63896203b29fd3a08a1f5036ca62d6d0c2 +e1Vlh7LNMFJ diff --git a/examples/directories/directories.hash b/examples/directories/directories.hash index 8ab57f4..fa8c641 100644 --- a/examples/directories/directories.hash +++ b/examples/directories/directories.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +7df99bb0443cbe61600e6466782a66e76cf7d927 +6lC_YCFEXVl diff --git a/examples/environment-variables/environment-variables.hash b/examples/environment-variables/environment-variables.hash index 8ab57f4..3177ea5 100644 --- a/examples/environment-variables/environment-variables.hash +++ b/examples/environment-variables/environment-variables.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +61c3cd2ec3ab8fcd4528452e88fe25c0eafbb2de +--fC2aTdXEz diff --git a/examples/errors/errors.hash b/examples/errors/errors.hash index 8ab57f4..7c79ad8 100644 --- a/examples/errors/errors.hash +++ b/examples/errors/errors.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +91979262128065a70899eb9ee32da1549864b609 +9-iENtmoI5k diff --git a/examples/execing-processes/execing-processes.hash b/examples/execing-processes/execing-processes.hash index 8ab57f4..d0dcce3 100644 --- a/examples/execing-processes/execing-processes.hash +++ b/examples/execing-processes/execing-processes.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +878cb29aa644aef60217a2d97a586080cd783daa +dojmebwCvC4 diff --git a/examples/exit/exit.hash b/examples/exit/exit.hash index 8ab57f4..af49b62 100644 --- a/examples/exit/exit.hash +++ b/examples/exit/exit.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +450a55230493ea17b3b7aeef666f55f796c050a8 +BgQ_ag62q4k diff --git a/examples/file-paths/file-paths.hash b/examples/file-paths/file-paths.hash index 8ab57f4..fd63161 100644 --- a/examples/file-paths/file-paths.hash +++ b/examples/file-paths/file-paths.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +7bbdffb4411e01e9962593d1de16a5654fb780d4 +6VDVplbM_Sk diff --git a/examples/for/for.hash b/examples/for/for.hash index 8ab57f4..ff069d6 100644 --- a/examples/for/for.hash +++ b/examples/for/for.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +c478d7d6259b800c42307c0d520fb669109cb2f7 +Fv7uI0y_EWr diff --git a/examples/functions/functions.hash b/examples/functions/functions.hash index 8ab57f4..742cfe2 100644 --- a/examples/functions/functions.hash +++ b/examples/functions/functions.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +fe343c61ebf68660290e3717592e7904c47abad5 +4sH5Tv_SBoU diff --git a/examples/goroutines/goroutines.hash b/examples/goroutines/goroutines.hash index 8ab57f4..ab46c61 100644 --- a/examples/goroutines/goroutines.hash +++ b/examples/goroutines/goroutines.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +9de125c9da86967491563075071ccd110b95b8ef +79i2V9dLU15 diff --git a/examples/http-clients/http-clients.hash b/examples/http-clients/http-clients.hash index e550dd5..8f7dd6a 100644 --- a/examples/http-clients/http-clients.hash +++ b/examples/http-clients/http-clients.hash @@ -1,2 +1,2 @@ -ec8fd69aa19e54a7ea05d2a911f09d3a98f0396c -VxYIifr_UuH +4efc6eb143a0e04132f16fcf929f7eed232b897d +8Z80D4rlbaE diff --git a/examples/http-servers/http-servers.hash b/examples/http-servers/http-servers.hash index a491ac1..553440b 100644 --- a/examples/http-servers/http-servers.hash +++ b/examples/http-servers/http-servers.hash @@ -1,2 +1,2 @@ -a4e8d30b7a6f3a6abd96b916d81ce5930bad94f9 -lNuS9ysZmxH +0282a23b343fbbbf9e3cb32d1efd934c9d707d26 +xndCIK5Wo-Y diff --git a/examples/interfaces/interfaces.hash b/examples/interfaces/interfaces.hash index 8ab57f4..e0bd9e8 100644 --- a/examples/interfaces/interfaces.hash +++ b/examples/interfaces/interfaces.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +e09278982d7d148dd22c45730d0820659a7ecae8 +bS2bkTzP8cG diff --git a/examples/line-filters/line-filters.hash b/examples/line-filters/line-filters.hash index 8ab57f4..298af0b 100644 --- a/examples/line-filters/line-filters.hash +++ b/examples/line-filters/line-filters.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +92a88a19fb7453935093e2ae893fcef18432f596 +dLiHA3PDCFp diff --git a/examples/maps/maps.hash b/examples/maps/maps.hash index 8ab57f4..3f261eb 100644 --- a/examples/maps/maps.hash +++ b/examples/maps/maps.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +df6205e7069d3914f2a40940696755f4b6343a9b +HjBZNUEcF_e diff --git a/examples/methods/methods.hash b/examples/methods/methods.hash index 8ab57f4..37ab1b3 100644 --- a/examples/methods/methods.hash +++ b/examples/methods/methods.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +b3128d2e4d2238e56d99bfc7138389257076871f +qfALObNYETK diff --git a/examples/multiple-return-values/multiple-return-values.hash b/examples/multiple-return-values/multiple-return-values.hash index 8ab57f4..9a8cf5c 100644 --- a/examples/multiple-return-values/multiple-return-values.hash +++ b/examples/multiple-return-values/multiple-return-values.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +9cfe1eb1a10a8977bee1581389953af18afc9bc0 +6Khmls9Dsin diff --git a/examples/mutexes/mutexes.hash b/examples/mutexes/mutexes.hash index 8ab57f4..501066e 100644 --- a/examples/mutexes/mutexes.hash +++ b/examples/mutexes/mutexes.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +8c7db363d911ef04d1340ff195da03a5373b79ab +USO1aTX_xMe diff --git a/examples/non-blocking-channel-operations/non-blocking-channel-operations.hash b/examples/non-blocking-channel-operations/non-blocking-channel-operations.hash index 8ab57f4..70fa503 100644 --- a/examples/non-blocking-channel-operations/non-blocking-channel-operations.hash +++ b/examples/non-blocking-channel-operations/non-blocking-channel-operations.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +3b01f109970c31ffb1c67cfea86a8eaa2959f7e0 +FokCtF5TvgL diff --git a/examples/number-parsing/number-parsing.hash b/examples/number-parsing/number-parsing.hash index 8ab57f4..40ced04 100644 --- a/examples/number-parsing/number-parsing.hash +++ b/examples/number-parsing/number-parsing.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +9b4a9b30f02201adf86ab6c6abc60e23088026be +4PKUrIjNyTE diff --git a/examples/pointers/pointers.hash b/examples/pointers/pointers.hash index 8ab57f4..69d7ef2 100644 --- a/examples/pointers/pointers.hash +++ b/examples/pointers/pointers.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +909a2f7a79ef942a544292b283a964ae530fd612 +VHnMkOQfQea diff --git a/examples/random-numbers/random-numbers.hash b/examples/random-numbers/random-numbers.hash index 8ab57f4..acd1836 100644 --- a/examples/random-numbers/random-numbers.hash +++ b/examples/random-numbers/random-numbers.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +03975452ff4c127a4a78897643ce3eca0b90b239 +CKeOTktHnJe diff --git a/examples/range-over-channels/range-over-channels.hash b/examples/range-over-channels/range-over-channels.hash index 8ab57f4..0200e30 100644 --- a/examples/range-over-channels/range-over-channels.hash +++ b/examples/range-over-channels/range-over-channels.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +a2f106b835828ac784feffb869604e059d788680 +zbl7ytLnFCK diff --git a/examples/range/range.hash b/examples/range/range.hash index 8ab57f4..a1df701 100644 --- a/examples/range/range.hash +++ b/examples/range/range.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +f8c6ffeaa1f52aeff136779442bbd160313a6b32 +4GBukIe-7ie diff --git a/examples/rate-limiting/rate-limiting.hash b/examples/rate-limiting/rate-limiting.hash index 8ab57f4..19e0c2c 100644 --- a/examples/rate-limiting/rate-limiting.hash +++ b/examples/rate-limiting/rate-limiting.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +a93813bfc920c685c55bf09a3425f63fcc4a542b +rC0qLhImKAo diff --git a/examples/reading-files/reading-files.hash b/examples/reading-files/reading-files.hash index 8ab57f4..24886b8 100644 --- a/examples/reading-files/reading-files.hash +++ b/examples/reading-files/reading-files.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +176b57caf5a053e3707da299ca9fbb78314d283f +m6mvXlZtHTX diff --git a/examples/recursion/recursion.hash b/examples/recursion/recursion.hash index 8ab57f4..26a2e36 100644 --- a/examples/recursion/recursion.hash +++ b/examples/recursion/recursion.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +b75f7597af0526d0fefb481ef7987b5e186c0c04 +oPbHEHLaRrN diff --git a/examples/regular-expressions/regular-expressions.hash b/examples/regular-expressions/regular-expressions.hash index 8ab57f4..fbd8efc 100644 --- a/examples/regular-expressions/regular-expressions.hash +++ b/examples/regular-expressions/regular-expressions.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +984c5939e46284833637df8aa8dd38f51b571425 +GB_bgVcRKg2 diff --git a/examples/sha1-hashes/sha1-hashes.hash b/examples/sha1-hashes/sha1-hashes.hash index 5af2939..b69d352 100644 --- a/examples/sha1-hashes/sha1-hashes.hash +++ b/examples/sha1-hashes/sha1-hashes.hash @@ -1,2 +1,2 @@ -4cda643ba233014fe6b30966c37d4d0fcd4edbe8 -oqcrTfY4Ykd +f64d96d9e998d1c8821689af70580b3929a464cf +zhhfA6LqgFI diff --git a/examples/signals/signals.hash b/examples/signals/signals.hash index 8ab57f4..02bac3b 100644 --- a/examples/signals/signals.hash +++ b/examples/signals/signals.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +8e3867a11504ce30880c75e3d5ed74907a8ef1b5 +Xs9zJ53YIAa diff --git a/examples/slices/slices.hash b/examples/slices/slices.hash index 8ab57f4..a4ad5e8 100644 --- a/examples/slices/slices.hash +++ b/examples/slices/slices.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +97236c6deebee661d0bd1e696b12e4ea671d06ff +32lRsL-MYrP diff --git a/examples/sorting-by-functions/sorting-by-functions.hash b/examples/sorting-by-functions/sorting-by-functions.hash index 8ab57f4..374e267 100644 --- a/examples/sorting-by-functions/sorting-by-functions.hash +++ b/examples/sorting-by-functions/sorting-by-functions.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +0252f365e73e310a8f4dc4431f598ffcea3efc72 +VQrgvKKcvRg diff --git a/examples/sorting/sorting.hash b/examples/sorting/sorting.hash index 8ab57f4..c28118f 100644 --- a/examples/sorting/sorting.hash +++ b/examples/sorting/sorting.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +a059f86c91ed4084fb37f321a7def4ef88b62e67 +X9bT-mDzj4o diff --git a/examples/spawning-processes/spawning-processes.hash b/examples/spawning-processes/spawning-processes.hash index 8ab57f4..2ccab24 100644 --- a/examples/spawning-processes/spawning-processes.hash +++ b/examples/spawning-processes/spawning-processes.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +4984e90d62323e378c35e5c52d0c5646fd150d82 +2QNUQPuiFlR diff --git a/examples/stateful-goroutines/stateful-goroutines.hash b/examples/stateful-goroutines/stateful-goroutines.hash index 8ab57f4..bb70ee5 100644 --- a/examples/stateful-goroutines/stateful-goroutines.hash +++ b/examples/stateful-goroutines/stateful-goroutines.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +e7e07404454809cbacb719ad94e70726d22dacc1 +n_gVZus4DBP diff --git a/examples/string-formatting/string-formatting.hash b/examples/string-formatting/string-formatting.hash index 8ab57f4..a8fe8ea 100644 --- a/examples/string-formatting/string-formatting.hash +++ b/examples/string-formatting/string-formatting.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +8ffedfce40621f09c42f07459127279d66425d08 +TKe8eifne_2 diff --git a/examples/string-functions/string-functions.hash b/examples/string-functions/string-functions.hash index 8ab57f4..e720ebb 100644 --- a/examples/string-functions/string-functions.hash +++ b/examples/string-functions/string-functions.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +818faf1a5caccb1628010427eff861edd8379de8 +UeDwSoYepQt diff --git a/examples/structs/structs.hash b/examples/structs/structs.hash index 8ab57f4..f0189fa 100644 --- a/examples/structs/structs.hash +++ b/examples/structs/structs.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +995a3c5dec1de68fe79d5d3172531fb5d2b99870 +sJZCI3Gm3Ht diff --git a/examples/temporary-files-and-directories/temporary-files-and-directories.hash b/examples/temporary-files-and-directories/temporary-files-and-directories.hash index 8ab57f4..e68654d 100644 --- a/examples/temporary-files-and-directories/temporary-files-and-directories.hash +++ b/examples/temporary-files-and-directories/temporary-files-and-directories.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +99866fef55916b593bf73df9591ca9d7d2c86d7e +PMJP7pf-n5h diff --git a/examples/testing/testing.hash b/examples/testing/testing.hash index 8ab57f4..3f809e1 100644 --- a/examples/testing/testing.hash +++ b/examples/testing/testing.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +1a41d8c725f8bfe62838744d6327404ec1ddc319 +gZXCCqO7ezT diff --git a/examples/tickers/tickers.hash b/examples/tickers/tickers.hash index 8ab57f4..b4fefad 100644 --- a/examples/tickers/tickers.hash +++ b/examples/tickers/tickers.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +64772226ab38092e29f23802c8138a723e23cc83 +2bpsxisGGLj diff --git a/examples/time-formatting-parsing/time-formatting-parsing.hash b/examples/time-formatting-parsing/time-formatting-parsing.hash index 8ab57f4..892e30e 100644 --- a/examples/time-formatting-parsing/time-formatting-parsing.hash +++ b/examples/time-formatting-parsing/time-formatting-parsing.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +7a8299db21f9554a2b43ecece2d8abf7a370189c +G61ruGfMQZA diff --git a/examples/time/time.hash b/examples/time/time.hash index 8ab57f4..15db181 100644 --- a/examples/time/time.hash +++ b/examples/time/time.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +e532cf20c51b0106aba8c041ec44480f7690da5e +ZE4n1Jt55m0 diff --git a/examples/timeouts/timeouts.hash b/examples/timeouts/timeouts.hash index 8ab57f4..91d44dc 100644 --- a/examples/timeouts/timeouts.hash +++ b/examples/timeouts/timeouts.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +441dc07d57c03df070488f85dbe24e5ef6591bf7 +SCMyPsGlXtX diff --git a/examples/timers/timers.hash b/examples/timers/timers.hash index 8ab57f4..87c1ff7 100644 --- a/examples/timers/timers.hash +++ b/examples/timers/timers.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +d1689f059a29e7e0d3f9ccd52632220d487d6ca0 +7RnBhz_kuki diff --git a/examples/url-parsing/url-parsing.hash b/examples/url-parsing/url-parsing.hash index 77021f1..28c5bcd 100644 --- a/examples/url-parsing/url-parsing.hash +++ b/examples/url-parsing/url-parsing.hash @@ -1,2 +1,2 @@ -babc12f5066652f4cb0151231c06f1037298ff28 -M218D9Tldlr +f0b0a50b3471f972b26e6fefb481730661aac6e1 +Zt1KHMGZESo diff --git a/examples/values/values.hash b/examples/values/values.hash index 8ab57f4..3716621 100644 --- a/examples/values/values.hash +++ b/examples/values/values.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +1c4cf252844f42861e8fbc59a604833d0dbd24c0 +SYLIv-rApFj diff --git a/examples/variables/variables.hash b/examples/variables/variables.hash index 8ab57f4..76bfeee 100644 --- a/examples/variables/variables.hash +++ b/examples/variables/variables.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +e5f981f078207ac4f67b26be87a73c2989006685 +BUbDhWP8PV_k diff --git a/examples/variadic-functions/variadic-functions.hash b/examples/variadic-functions/variadic-functions.hash index 8ab57f4..46c87a0 100644 --- a/examples/variadic-functions/variadic-functions.hash +++ b/examples/variadic-functions/variadic-functions.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +e32d27f8b78c3e3f24c5dd98f864ffdb9567d628 +dz6tVXvffuH diff --git a/examples/worker-pools/worker-pools.hash b/examples/worker-pools/worker-pools.hash index 8ab57f4..fc92632 100644 --- a/examples/worker-pools/worker-pools.hash +++ b/examples/worker-pools/worker-pools.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +a719d863a0b07434beade5c6582eff76df8bd2ef +79qTVPHnwGQ diff --git a/examples/writing-files/writing-files.hash b/examples/writing-files/writing-files.hash index 8ab57f4..89cec11 100644 --- a/examples/writing-files/writing-files.hash +++ b/examples/writing-files/writing-files.hash @@ -1,2 +1,2 @@ -da39a3ee5e6b4b0d3255bfef95601890afd80709 -UCPdVNrl0-P +f6c74f9903720805417ffe5765cef04e3f58d966 +LscGbwmQZns diff --git a/public/404.html b/public/404.html deleted file mode 100644 index e2a089e..0000000 --- a/public/404.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - Go by Example: Not Found - - - -
-

Go by Example

-

Sorry, we couldn't find that! Check out the home page?

- -
- - diff --git a/public/arrays b/public/arrays deleted file mode 100644 index d19bf1c..0000000 --- a/public/arrays +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Массивы (Arrays) - - - - -
-

Go в примерах: Массивы (Arrays)

- - -

- Следующий пример: Срезы (Slices). -

- - -
- - - - diff --git a/public/atomic-counters b/public/atomic-counters deleted file mode 100644 index e073b4b..0000000 --- a/public/atomic-counters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Атомарные счетчики (Atomic Counters) - - - - -
-

Go в примерах: Атомарные счетчики (Atomic Counters)

- - -

- Следующий пример: Мьютексы (Mutexes). -

- - -
- - - - diff --git a/public/base64 b/public/base64 deleted file mode 100644 index eadbd1c..0000000 --- a/public/base64 +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Кодирование Base64 (Base64 Encoding) - - - - -
-

Go в примерах: Кодирование Base64 (Base64 Encoding)

- - -

- Следующий пример: Чтение файлов (Reading Files). -

- - -
- - - - diff --git a/public/channel-buffering b/public/channel-buffering deleted file mode 100644 index 36fd138..0000000 --- a/public/channel-buffering +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Буферизированный канал (Channel Buffering) - - - - -
-

Go в примерах: Буферизированный канал (Channel Buffering)

- - -

- Следующий пример: Синхронизация канала (Channel Synchronization). -

- - -
- - - - diff --git a/public/channel-directions b/public/channel-directions deleted file mode 100644 index f50b677..0000000 --- a/public/channel-directions +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Направления канала (Channel Directions) - - - - -
-

Go в примерах: Направления канала (Channel Directions)

- - -

- Следующий пример: Select. -

- - -
- - - - diff --git a/public/channel-synchronization b/public/channel-synchronization deleted file mode 100644 index b421afc..0000000 --- a/public/channel-synchronization +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Синхронизация канала (Channel Synchronization) - - - - -
-

Go в примерах: Синхронизация канала (Channel Synchronization)

- - -

- Следующий пример: Направления канала (Channel Directions). -

- - -
- - - - diff --git a/public/channels b/public/channels deleted file mode 100644 index 9711b17..0000000 --- a/public/channels +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Каналы (Channels) - - - - -
-

Go в примерах: Каналы (Channels)

- - -

- Следующий пример: Буферизированный канал (Channel Buffering). -

- - -
- - - - diff --git a/public/clipboard.png b/public/clipboard.png deleted file mode 100644 index 0e262fe..0000000 Binary files a/public/clipboard.png and /dev/null differ diff --git a/public/closing-channels b/public/closing-channels deleted file mode 100644 index fa1c91c..0000000 --- a/public/closing-channels +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Закрытие каналов (Closing Channels) - - - - -
-

Go в примерах: Закрытие каналов (Closing Channels)

- - -

- Следующий пример: Перебор значений из каналов (Range over Channels). -

- - -
- - - - diff --git a/public/closures b/public/closures deleted file mode 100644 index 1d3cbc4..0000000 --- a/public/closures +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Замыкания (Closures) - - - - -
-

Go в примерах: Замыкания (Closures)

- - -

- Следующий пример: Рекурсия (Recursion). -

- - -
- - - - diff --git a/public/collection-functions b/public/collection-functions deleted file mode 100644 index 9efcde8..0000000 --- a/public/collection-functions +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Функции коллекции (Collection Functions) - - - - -
-

Go в примерах: Функции коллекции (Collection Functions)

- - -

- Следующий пример: Строковые функции (String Functions). -

- - -
- - - - diff --git a/public/command-line-arguments b/public/command-line-arguments deleted file mode 100644 index d3857df..0000000 --- a/public/command-line-arguments +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Аргументы командной строки (Command-Line Arguments) - - - - -
-

Go в примерах: Аргументы командной строки (Command-Line Arguments)

- - -

- Следующий пример: Флаги командной строки (Command-Line Flags). -

- - -
- - - - diff --git a/public/command-line-flags b/public/command-line-flags deleted file mode 100644 index 97d6350..0000000 --- a/public/command-line-flags +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Флаги командной строки (Command-Line Flags) - - - - -
-

Go в примерах: Флаги командной строки (Command-Line Flags)

- - -

- Следующий пример: Подкоманды командной строки (Command-Line Subcommands). -

- - -
- - - - diff --git a/public/command-line-subcommands b/public/command-line-subcommands deleted file mode 100644 index f90fce7..0000000 --- a/public/command-line-subcommands +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Подкоманды командной строки (Command-Line Subcommands) - - - - -
-

Go в примерах: Подкоманды командной строки (Command-Line Subcommands)

- - -

- Следующий пример: Переменные среды (Environment Variables). -

- - -
- - - - diff --git a/public/constants b/public/constants deleted file mode 100644 index bc51abe..0000000 --- a/public/constants +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Константы (Constants) - - - - -
-

Go в примерах: Константы (Constants)

- - -

- Следующий пример: Цикл For. -

- - -
- - - - diff --git a/public/defer b/public/defer deleted file mode 100644 index 2beb109..0000000 --- a/public/defer +++ /dev/null @@ -1,220 +0,0 @@ - - - - - Go в примерах: Defer - - - - -
-

Go в примерах: Defer

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Defer используется, чтобы гарантировать, что -вызов функции будет выполнен позже при выполнении -программы, обычно для целей очистки. defer часто -используется там, где в других языках используются -ensure и finally.

- -
- - -
- - - -
package main
-
- -
- - - -
import (
-    "fmt"
-    "os"
-)
-
- -
-

Предположим, мы хотим создать файл, записать в него, -а затем закрыть, когда закончим. Вот как нам поможет -defer.

- -
- -
func main() {
-
- -
-

Сразу же после получения объекта файла с помощью -createFile мы откладываем закрытие этого файла -с помощью closeFile. Она будет выполнена в -конце включающей функции (main) после завершения -writeFile.

- -
- -
    f := createFile("/tmp/defer.txt")
-    defer closeFile(f)
-    writeFile(f)
-}
-
- -
- - - -
func createFile(p string) *os.File {
-    fmt.Println("creating")
-    f, err := os.Create(p)
-    if err != nil {
-        panic(err)
-    }
-    return f
-}
-
- -
- - - -
func writeFile(f *os.File) {
-    fmt.Println("writing")
-    fmt.Fprintln(f, "data")
-
- -
- - - -
}
-
- -
-

Важно проверять наличие ошибок при закрытии файла, -даже в отложенной функции.

- -
- -
func closeFile(f *os.File) {
-    fmt.Println("closing")
-    err := f.Close()
-
- -
- - - -
    if err != nil {
-        fmt.Fprintf(os.Stderr, "error: %v\n", err)
-        os.Exit(1)
-    }
-}
-
- -
- - - - - - - - -
-

Запуск программы подтверждает, что файл закрыт -после записи.

- -
- -
$ go run defer.go
-creating
-writing
-closing
-
- -
- - -

- Следующий пример: Функции коллекции (Collection Functions). -

- - -
- - - - diff --git a/public/directories b/public/directories deleted file mode 100644 index 2dd5c88..0000000 --- a/public/directories +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Директории (Directories) - - - - -
-

Go в примерах: Директории (Directories)

- - -

- Следующий пример: Временные файлы и директории (Temporary Files and Directories). -

- - -
- - - - diff --git a/public/environment-variables b/public/environment-variables deleted file mode 100644 index c08bf0e..0000000 --- a/public/environment-variables +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Переменные среды (Environment Variables) - - - - -
-

Go в примерах: Переменные среды (Environment Variables)

- - -

- Следующий пример: HTTP клиенты (HTTP Clients). -

- - -
- - - - diff --git a/public/epoch b/public/epoch deleted file mode 100644 index ddd321a..0000000 --- a/public/epoch +++ /dev/null @@ -1,183 +0,0 @@ - - - - - Go в примерах: Epoch - - - - -
-

Go в примерах: Epoch

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Общим требованием в программах является получение -количества секунд, миллисекунд или наносекунд в Unixtime. -Вот как это сделать в Go.

- -
- - -
- - - -
package main
-
- -
- - - -
import (
-    "fmt"
-    "time"
-)
-
- -
- - - -
func main() {
-
- -
-

Используйте time.Now с Unix или UnixNano, -чтобы получить время, прошедшее с начала эпохи Unix в -секундах или наносекундах соответственно.

- -
- -
    now := time.Now()
-    secs := now.Unix()
-    nanos := now.UnixNano()
-    fmt.Println(now)
-
- -
-

Обратите внимание, что UnixMillis не существует, -поэтому, чтобы получить миллисекунды с начала эпохи Unix, -вам нужно будет вручную делить наносекунды.

- -
- -
    millis := nanos / 1000000
-    fmt.Println(secs)
-    fmt.Println(millis)
-    fmt.Println(nanos)
-
- -
-

Вы также можете конвертировать целые секунды или наносекунды -Unixtime в соответствующее время.

- -
- -
    fmt.Println(time.Unix(secs, 0))
-    fmt.Println(time.Unix(0, nanos))
-}
-
- -
- - - - - - - - - - - - - -
- - - -
$ go run epoch.go 
-2012-10-31 16:13:58.292387 +0000 UTC
-1351700038
-1351700038292
-1351700038292387000
-2012-10-31 16:13:58 +0000 UTC
-2012-10-31 16:13:58.292387 +0000 UTC
-
- -
-

Далее мы рассмотрим еще одну задачу, связанную со -временем: разбор и форматирование времени.

- -
- - -
- - -

- Следующий пример: Форматирование времени (Time Formatting / Parsing). -

- - -
- - - - diff --git a/public/errors b/public/errors deleted file mode 100644 index d276119..0000000 --- a/public/errors +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Ошибки (Errors) - - - - -
-

Go в примерах: Ошибки (Errors)

- - -

- Следующий пример: Горутины (Goroutines). -

- - -
- - - - diff --git a/public/execing-processes b/public/execing-processes deleted file mode 100644 index e0cc10d..0000000 --- a/public/execing-processes +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Исполняющие процессы (Exec'ing Processes) - - - - -
-

Go в примерах: Исполняющие процессы (Exec'ing Processes)

- - -

- Следующий пример: Сигналы (Signals). -

- - -
- - - - diff --git a/public/exit b/public/exit deleted file mode 100644 index 50c7fbe..0000000 --- a/public/exit +++ /dev/null @@ -1,33 +0,0 @@ - - - - - Go в примерах: Выход (Exit) - - - - -
-

Go в примерах: Выход (Exit)

- - - -
- - - - diff --git a/public/favicon.ico b/public/favicon.ico deleted file mode 100644 index efa34a3..0000000 Binary files a/public/favicon.ico and /dev/null differ diff --git a/public/file-paths b/public/file-paths deleted file mode 100644 index b026eb7..0000000 --- a/public/file-paths +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Пути к файлам (File Paths) - - - - -
-

Go в примерах: Пути к файлам (File Paths)

- - -

- Следующий пример: Директории (Directories). -

- - -
- - - - diff --git a/public/for b/public/for deleted file mode 100644 index de2ea5f..0000000 --- a/public/for +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Цикл For - - - - -
-

Go в примерах: Цикл For

- - -

- Следующий пример: If/Else. -

- - -
- - - - diff --git a/public/functions b/public/functions deleted file mode 100644 index ef4f0db..0000000 --- a/public/functions +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Функции (Functions) - - - - -
-

Go в примерах: Функции (Functions)

- - -

- Следующий пример: Функции с множественным возвратом (Multiple Return Values). -

- - -
- - - - diff --git a/public/goroutines b/public/goroutines deleted file mode 100644 index dfcbc2d..0000000 --- a/public/goroutines +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Горутины (Goroutines) - - - - -
-

Go в примерах: Горутины (Goroutines)

- - -

- Следующий пример: Каналы (Channels). -

- - -
- - - - diff --git a/public/hello-world b/public/hello-world deleted file mode 100644 index 67c1c82..0000000 --- a/public/hello-world +++ /dev/null @@ -1,142 +0,0 @@ - - - - - Go в примерах: Hello World - - - - -
-

Go в примерах: Hello World

- - - - - - - - - - - - - - - - - - -
-

Наша первая программа напечатает классическое сообщение “hello world” -Полный код.

- -
- -
package main
-
- -
- - - -
import "fmt"
-
- -
- - - -
func main() {
-    fmt.Println("hello world")
-}
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
-

To run the program, put the code in hello-world.go and -use go run.

- -
- -
$ go run hello-world.go
-hello world
-
- -
-

Sometimes we’ll want to build our programs into -binaries. We can do this using go build.

- -
- -
$ go build hello-world.go
-$ ls
-hello-world    hello-world.go
-
- -
-

We can then execute the built binary directly.

- -
- -
$ ./hello-world
-hello world
-
- -
-

Now that we can run and build basic Go programs, let’s -learn more about the language.

- -
- - -
- - -

- Следующий пример: Типы данных (Values). -

- - -
- - - - diff --git a/public/http b/public/http deleted file mode 100644 index 1ddb1a7..0000000 --- a/public/http +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: HTTP серверы (HTTP Servers) - - - - -
-

Go в примерах: HTTP серверы (HTTP Servers)

- - -

- Следующий пример: Порождающие процессы (Spawning Processes). -

- - -
- - - - diff --git a/public/if-else b/public/if-else deleted file mode 100644 index fc7514b..0000000 --- a/public/if-else +++ /dev/null @@ -1,191 +0,0 @@ - - - - - Go в примерах: If/Else - - - - -
-

Go в примерах: If/Else

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Условные операторы if иelse в Go -выглядят достаточно стандартно

- -
- - -
- - - -
package main
-
- -
- - - -
import "fmt"
-
- -
- - - -
func main() {
-
- -
-

Стандартное использование

- -
- -
    if 7%2 == 0 {
-        fmt.Println("7 is even")
-    } else {
-        fmt.Println("7 is odd")
-    }
-
- -
-

Вы можете использовать блоке if без блока else.

- -
- -
    if 8%4 == 0 {
-        fmt.Println("8 is divisible by 4")
-    }
-
- -
-

Присваивание переменной может происходить до условия. -Любые определенные значения будут доступны в -последующих ветках

- -
- -
    if num := 9; num < 0 {
-        fmt.Println(num, "is negative")
-    } else if num < 10 {
-        fmt.Println(num, "has 1 digit")
-    } else {
-        fmt.Println(num, "has multiple digits")
-    }
-}
-
- -
-

Имейте ввиду, что в Go не надо использовать скобки в условии, -но блок необходимо заключать в фигурные скобки

- -
- - -
- - - - - - - - - - - - - -
- - - -
$ go run if-else.go 
-7 is odd
-8 is divisible by 4
-9 has 1 digit
-
- -
-

There is no ternary if -in Go, so you’ll need to use a full if statement even -for basic conditions.

- -
- - -
- - -

- Следующий пример: Switch. -

- - -
- - - - diff --git a/public/index.html b/public/index.html deleted file mode 100644 index c777850..0000000 --- a/public/index.html +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Go в примерах - - - -
-

Go в примерах

-

- Go - это язык программирования с - открытым исходным кодом, предназначенный для создания простого, - быстрого и надежного программного обеспечения. -

- -

- Go в примерах Go by Example - это практическое введение - в Go с использованием примеров реальных программ. Проверьте - первый пример или просмотрите полный - список ниже. -

- - - -
- - diff --git a/public/interfaces b/public/interfaces deleted file mode 100644 index 9c13931..0000000 --- a/public/interfaces +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Интерфейсы (Interfaces) - - - - -
-

Go в примерах: Интерфейсы (Interfaces)

- - -

- Следующий пример: Ошибки (Errors). -

- - -
- - - - diff --git a/public/json b/public/json deleted file mode 100644 index 9e541cf..0000000 --- a/public/json +++ /dev/null @@ -1,424 +0,0 @@ - - - - - Go в примерах: JSON - - - - -
-

Go в примерах: JSON

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Go предлагает встроенную поддержку кодирования и -декодирования JSON, в том числе встроенных и -пользовательских типов данных.

- -
- - -
- - - -
package main
-
- -
- - - -
import (
-    "encoding/json"
-    "fmt"
-    "os"
-)
-
- -
-

Мы будем использовать эти две структуры, для демонстрации -кодирования и декодирования.

- -
- -
type response1 struct {
-    Page   int
-    Fruits []string
-}
-
- -
-

Только экспортируемые поля могут быть кодированы и -декодированы в JSON. Поля должны начинаться с -заглавной буквы.

- -
- -
type response2 struct {
-    Page   int      `json:"page"`
-    Fruits []string `json:"fruits"`
-}
-
- -
- - - -
func main() {
-
- -
-

Для начала мы рассмотрим кодирование данных в -JSON строку. Вот несколько примеров для простых -типов данных.

- -
- -
    bolB, _ := json.Marshal(true)
-    fmt.Println(string(bolB))
-
- -
- - - -
    intB, _ := json.Marshal(1)
-    fmt.Println(string(intB))
-
- -
- - - -
    fltB, _ := json.Marshal(2.34)
-    fmt.Println(string(fltB))
-
- -
- - - -
    strB, _ := json.Marshal("gopher")
-    fmt.Println(string(strB))
-
- -
-

А вот примеры для срезов и карт, которые кодируются -в JSON массивы и объекты, как мы и ожидаем.

- -
- -
    slcD := []string{"apple", "peach", "pear"}
-    slcB, _ := json.Marshal(slcD)
-    fmt.Println(string(slcB))
-
- -
- - - -
    mapD := map[string]int{"apple": 5, "lettuce": 7}
-    mapB, _ := json.Marshal(mapD)
-    fmt.Println(string(mapB))
-
- -
-

Пакет JSON может автоматически кодировать ваши -пользовательские типы данных. Он будет включать -только экспортируемые поля в закодированный -вывод и по умолчанию будет использовать эти -имена в качестве ключей JSON.

- -
- -
    res1D := &response1{
-        Page:   1,
-        Fruits: []string{"apple", "peach", "pear"}}
-    res1B, _ := json.Marshal(res1D)
-    fmt.Println(string(res1B))
-
- -
-

Вы можете использовать теги в объявлениях -структурных полей для настройки кодированных имен -ключей JSON. Проверьте определение response2 -выше, чтобы увидеть пример таких тегов.

- -
- -
    res2D := &response2{
-        Page:   1,
-        Fruits: []string{"apple", "peach", "pear"}}
-    res2B, _ := json.Marshal(res2D)
-    fmt.Println(string(res2B))
-
- -
-

Теперь давайте рассмотрим декодирование данных -JSON в значения Go. Вот пример для общей -структуры данных.

- -
- -
    byt := []byte(`{"num":6.13,"strs":["a","b"]}`)
-
- -
-

Нам нужно предоставить переменную, в которую пакет -JSON может поместить декодированные данные. -`map[string]interface{} будет содержать карту -строк для произвольных типов данных.

- -
- -
    var dat map[string]interface{}
-
- -
-

Вот фактическое декодирование и проверка на наличие -ошибок.

- -
- -
    if err := json.Unmarshal(byt, &dat); err != nil {
-        panic(err)
-    }
-    fmt.Println(dat)
-
- -
-

Чтобы использовать значения в декодированной карте, -нам нужно преобразовать их в соответствующий тип. -Например, здесь мы конвертируем значение из num -в ожидаемый тип float64.

- -
- -
    num := dat["num"].(float64)
-    fmt.Println(num)
-
- -
-

Доступ к вложенным данным требует ряда преобразований.

- -
- -
    strs := dat["strs"].([]interface{})
-    str1 := strs[0].(string)
-    fmt.Println(str1)
-
- -
-

Мы также можем декодировать JSON в пользовательские -типы данных. Это дает преимущество добавления -дополнительной безопасности типов в наши программы -и устранения необходимости в определении типрв -при доступе к декодированным данным.

- -
- -
    str := `{"page": 1, "fruits": ["apple", "peach"]}`
-    res := response2{}
-    json.Unmarshal([]byte(str), &res)
-    fmt.Println(res)
-    fmt.Println(res.Fruits[0])
-
- -
-

В приведенных выше примерах мы всегда использовали -байты и строки в качестве промежуточных звеньев между -данными и представлением JSON на стандартном выходе. -Мы также можем транслировать JSON-кодировки напрямую -в os.Writer, такие как os.Stdout или даже HTTP-тела -ответа.

- -
- -
    enc := json.NewEncoder(os.Stdout)
-    d := map[string]int{"apple": 5, "lettuce": 7}
-    enc.Encode(d)
-}
-
- -
- - - - - - - - - - - - - -
- - - -
$ go run json.go
-true
-1
-2.34
-"gopher"
-["apple","peach","pear"]
-{"apple":5,"lettuce":7}
-{"Page":1,"Fruits":["apple","peach","pear"]}
-{"page":1,"fruits":["apple","peach","pear"]}
-map[num:6.13 strs:[a b]]
-6.13
-a
-{1 [apple peach]}
-apple
-{"apple":5,"lettuce":7}
-
- -
-

Мы рассмотрели основы JSON в Go, но ознакомьтесь с -публикацией в блоге JSON and Go -и документацией по пакету JSON.

- -
- - -
- - -

- Следующий пример: XML. -

- - -
- - - - diff --git a/public/line-filters b/public/line-filters deleted file mode 100644 index 92aaa21..0000000 --- a/public/line-filters +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Строковые фильтры (Line Filters) - - - - -
-

Go в примерах: Строковые фильтры (Line Filters)

- - -

- Следующий пример: Пути к файлам (File Paths). -

- - -
- - - - diff --git a/public/maps b/public/maps deleted file mode 100644 index 8d69719..0000000 --- a/public/maps +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Карты (Maps) - - - - -
-

Go в примерах: Карты (Maps)

- - -

- Следующий пример: Ряд (Range). -

- - -
- - - - diff --git a/public/methods b/public/methods deleted file mode 100644 index 268a326..0000000 --- a/public/methods +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Методы (Methods) - - - - -
-

Go в примерах: Методы (Methods)

- - -

- Следующий пример: Интерфейсы (Interfaces). -

- - -
- - - - diff --git a/public/multiple-return-values b/public/multiple-return-values deleted file mode 100644 index fc6717b..0000000 --- a/public/multiple-return-values +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Функции с множественным возвратом (Multiple Return Values) - - - - -
-

Go в примерах: Функции с множественным возвратом (Multiple Return Values)

- - -

- Следующий пример: Функции с переменным числом аргументов (Variadic Functions). -

- - -
- - - - diff --git a/public/mutexes b/public/mutexes deleted file mode 100644 index 571bd6e..0000000 --- a/public/mutexes +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Мьютексы (Mutexes) - - - - -
-

Go в примерах: Мьютексы (Mutexes)

- - -

- Следующий пример: Управление состоянием горутин (Stateful Goroutines). -

- - -
- - - - diff --git a/public/non-blocking-channel-operations b/public/non-blocking-channel-operations deleted file mode 100644 index 754f365..0000000 --- a/public/non-blocking-channel-operations +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Неблокируемые операции в каналах (Non-Blocking Channel Operations) - - - - -
-

Go в примерах: Неблокируемые операции в каналах (Non-Blocking Channel Operations)

- - -

- Следующий пример: Закрытие каналов (Closing Channels). -

- - -
- - - - diff --git a/public/number-parsing b/public/number-parsing deleted file mode 100644 index 1cf3b50..0000000 --- a/public/number-parsing +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Парсинг чисел (Number Parsing) - - - - -
-

Go в примерах: Парсинг чисел (Number Parsing)

- - -

- Следующий пример: Парсинг URL (URL Parsing). -

- - -
- - - - diff --git a/public/panic b/public/panic deleted file mode 100644 index d393582..0000000 --- a/public/panic +++ /dev/null @@ -1,183 +0,0 @@ - - - - - Go в примерах: Panic - - - - -
-

Go в примерах: Panic

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Panic обычно означает, что что-то неожиданно пошло -не так. В основном мы используем его для быстрого -отказа при ошибках, которые не должны возникать во -время нормальной работы, или которые мы не готовы -обрабатывать.

- -
- - -
- - - -
package main
-
- -
- - - -
import "os"
-
- -
- - - -
func main() {
-
- -
-

Мы будем использовать panic на этом сайте, чтобы -проверять наличие неожиданных ошибок. Это -единственная программа на сайте, предназначенная -для паники.

- -
- -
    panic("a problem")
-
- -
-

Обычное использование panic - это прерывание, -если функция возвращает значение ошибки, которое -мы не знаем, как (или хотим) обрабатывать. Вот -пример panic, если мы получаем неожиданную ошибку -при создании нового файла.

- -
- -
    _, err := os.Create("/tmp/file")
-    if err != nil {
-        panic(err)
-    }
-}
-
- -
- - - - - - - - - - - - - - - - - - -
-

Запуск этой программы вызовет панику, распечатает -сообщение об ошибке и трейс выполнения и завершит -работу с ненулевым статусом.

- -
- -
$ go run panic.go
-panic: a problem
-
- -
- - - -
goroutine 1 [running]:
-main.main()
-    /.../panic.go:12 +0x47
-...
-exit status 2
-
- -
-

Обратите внимание, что в отличие от некоторых языков, -которые используют исключения для обработки -ошибок, в Go привычно использовать возвращающие -значения, указывающие на ошибки.

- -
- - -
- - -

- Следующий пример: Defer. -

- - -
- - - - diff --git a/public/play.png b/public/play.png deleted file mode 100644 index ec7028c..0000000 Binary files a/public/play.png and /dev/null differ diff --git a/public/pointers b/public/pointers deleted file mode 100644 index 37d75c0..0000000 --- a/public/pointers +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Указатели (Pointers) - - - - -
-

Go в примерах: Указатели (Pointers)

- - -

- Следующий пример: Структуры (Structs). -

- - -
- - - - diff --git a/public/random-numbers b/public/random-numbers deleted file mode 100644 index eb1856a..0000000 --- a/public/random-numbers +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Случайные числа (Random Numbers) - - - - -
-

Go в примерах: Случайные числа (Random Numbers)

- - -

- Следующий пример: Парсинг чисел (Number Parsing). -

- - -
- - - - diff --git a/public/range b/public/range deleted file mode 100644 index 17e52bb..0000000 --- a/public/range +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Ряд (Range) - - - - -
-

Go в примерах: Ряд (Range)

- - -

- Следующий пример: Функции (Functions). -

- - -
- - - - diff --git a/public/range-over-channels b/public/range-over-channels deleted file mode 100644 index e9724c5..0000000 --- a/public/range-over-channels +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Перебор значений из каналов (Range over Channels) - - - - -
-

Go в примерах: Перебор значений из каналов (Range over Channels)

- - -

- Следующий пример: Таймеры (Timers). -

- - -
- - - - diff --git a/public/rate-limiting b/public/rate-limiting deleted file mode 100644 index e55807e..0000000 --- a/public/rate-limiting +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Ограничение скорости (Rate Limiting) - - - - -
-

Go в примерах: Ограничение скорости (Rate Limiting)

- - -

- Следующий пример: Атомарные счетчики (Atomic Counters). -

- - -
- - - - diff --git a/public/reading-files b/public/reading-files deleted file mode 100644 index eeab811..0000000 --- a/public/reading-files +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Чтение файлов (Reading Files) - - - - -
-

Go в примерах: Чтение файлов (Reading Files)

- - -

- Следующий пример: Запись файлов (Writing Files). -

- - -
- - - - diff --git a/public/recursion b/public/recursion deleted file mode 100644 index a7bf95e..0000000 --- a/public/recursion +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Рекурсия (Recursion) - - - - -
-

Go в примерах: Рекурсия (Recursion)

- - -

- Следующий пример: Указатели (Pointers). -

- - -
- - - - diff --git a/public/regular-expressions b/public/regular-expressions deleted file mode 100644 index 700db55..0000000 --- a/public/regular-expressions +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Регулярные выражения (Regular Expressions) - - - - -
-

Go в примерах: Регулярные выражения (Regular Expressions)

- - -

- Следующий пример: JSON. -

- - -
- - - - diff --git a/public/select b/public/select deleted file mode 100644 index f45e57e..0000000 --- a/public/select +++ /dev/null @@ -1,192 +0,0 @@ - - - - - Go в примерах: Select - - - - -
-

Go в примерах: Select

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Go’s _select позволяет вам ждать нескольких -операций на канале. Сочетание горутин и каналов -с помощью select’а - мощная функция Go.

- -
- - -
- - - -
package main
-
- -
- - - -
import (
-    "fmt"
-    "time"
-)
-
- -
- - - -
func main() {
-
- -
-

В нашем примере мы будем выбирать между двумя -каналами.

- -
- -
    c1 := make(chan string)
-    c2 := make(chan string)
-
- -
-

Каждый канал получит значение через некоторое время, -например, для моделирования блокировки RPC-операций, -выполняемых в параллельных горутинах.

- -
- -
    go func() {
-        time.Sleep(1 * time.Second)
-        c1 <- "one"
-    }()
-    go func() {
-        time.Sleep(2 * time.Second)
-        c2 <- "two"
-    }()
-
- -
-

Мы будем использовать select, чтобы ожидать -оба значения одновременно, печатая каждое из -них по мере поступления.

- -
- -
    for i := 0; i < 2; i++ {
-        select {
-        case msg1 := <-c1:
-            fmt.Println("received", msg1)
-        case msg2 := <-c2:
-            fmt.Println("received", msg2)
-        }
-    }
-}
-
- -
- - - - - - - - - - - - - -
-

Мы получаем значние "one" и потом "two", как -и ожидалось.

- -
- -
$ time go run select.go 
-received one
-received two
-
- -
-

Обратите внимание, что общее время выполнения -составляет всего ~2 секунды, так как и 1, и 2 секунды -Sleeps выполняются одновременно.

- -
- -
real    0m2.245s
-
- -
- - -

- Следующий пример: Тайм-ауты (Timeouts). -

- - -
- - - - diff --git a/public/sha1 b/public/sha1 deleted file mode 100644 index daf6a09..0000000 --- a/public/sha1 +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Хеш SHA1 (SHA1 Hashes) - - - - -
-

Go в примерах: Хеш SHA1 (SHA1 Hashes)

- - -

- Следующий пример: Кодирование Base64 (Base64 Encoding). -

- - -
- - - - diff --git a/public/signals b/public/signals deleted file mode 100644 index d4b3432..0000000 --- a/public/signals +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Сигналы (Signals) - - - - -
-

Go в примерах: Сигналы (Signals)

- - -

- Следующий пример: Выход (Exit). -

- - -
- - - - diff --git a/public/site.css b/public/site.css deleted file mode 100644 index 7e93afb..0000000 --- a/public/site.css +++ /dev/null @@ -1,212 +0,0 @@ -/* CSS reset: http://meyerweb.com/eric/tools/css/reset/ */ -html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -b, u, i, center, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td, -article, aside, canvas, details, embed, -figure, figcaption, footer, header, hgroup, -menu, nav, output, ruby, section, summary, -time, mark, audio, video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; -} -article, aside, details, figcaption, figure, -footer, header, hgroup, menu, nav, section { - display: block; -} -body { - line-height: 1; -} -ol, ul { - list-style: none; -} -blockquote, q { - quotes: none; -} -blockquote:before, blockquote:after, -q:before, q:after { - content: ''; - content: none; -} -table { - border-collapse: collapse; - border-spacing: 0; -} - -/* Layout and typography */ -body { - font-family: 'Georgia', serif; - font-size: 16px; - line-height: 20px; - color: #252519; -} -em { - font-style: italic; -} -a, a:visited { - color: #261a3b; -} -h2 { - font-size: 32px; - line-height: 40px; - margin-top: 40px; -} -h2 a { - text-decoration: none; -} -div.example { - width: 900px; - min-width: 900px; - max-width: 900px; - margin-left: auto; - margin-right: auto; - margin-bottom: 120px; -} -div.example table { - margin-top: 15px; - margin-bottom: 20px; -} -p.next { - margin-bottom: 20px; -} -p.footer { - color: grey; -} -p.footer a, p.footer a:visited { - color: grey; -} -div#intro { - width: 420px; - min-width: 420px; - max-width: 420px; - margin-left: auto; - margin-right: auto; - margin-bottom: 120px; -} -div#intro p { - padding-top: 20px; -} -div#intro ul { - padding-top: 20px; -} -table td { - border: 0; - outline: 0; -} -td.docs { - width: 420px; - max-width: 420px; - min-width: 420px; - min-height: 5px; - vertical-align: top; - text-align: left; -} -td.docs p { - padding-right: 5px; - padding-top: 5px; - padding-bottom: 15px; -} -td.code { - width: 480px; - max-width: 480px; - min-width: 480px; - padding-top: 5px; - padding-right: 5px; - padding-left: 5px; - padding-bottom: 5px; - vertical-align: top; - background: #f0f0f0; -} -td.code.leading { - padding-bottom: 11px; -} -td.code.empty { - background: #ffffff; -} -pre, code { - font-size: 14px; line-height: 18px; - font-family: 'Menlo', 'Monaco', 'Consolas', 'Lucida Console', monospace; -} -img.copy, img.run { - height: 16px; - width: 16px; - float: right -} -img.copy, img.run { - cursor: pointer; -} -img.copy { - margin-right: 4px; -} - -/* Syntax highlighting */ -body .hll { background-color: #ffffcc } -body .err { border: 1px solid #FF0000 } /* Error */ -body .c { color: #408080; font-style: italic } /* Comment */ -body .k { color: #954121 } /* Keyword */ -body .o { color: #666666 } /* Operator */ -body .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -body .cp { color: #BC7A00 } /* Comment.Preproc */ -body .c1 { color: #408080; font-style: italic } /* Comment.Single */ -body .cs { color: #408080; font-style: italic } /* Comment.Special */ -body .gd { color: #A00000 } /* Generic.Deleted */ -body .ge { font-style: italic } /* Generic.Emph */ -body .gr { color: #FF0000 } /* Generic.Error */ -body .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -body .gi { color: #00A000 } /* Generic.Inserted */ -body .go { color: #808080 } /* Generic.Output */ -body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -body .gs { font-weight: bold } /* Generic.Strong */ -body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -body .gt { color: #0040D0 } /* Generic.Traceback */ -body .kc { color: #954121 } /* Keyword.Constant */ -body .kd { color: #954121 } /* Keyword.Declaration */ -body .kn { color: #954121 } /* Keyword.Namespace */ -body .kp { color: #954121 } /* Keyword.Pseudo */ -body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */ -body .kt { color: #B00040 } /* Keyword.Type */ -body .m { color: #666666 } /* Literal.Number */ -body .s { color: #219161 } /* Literal.String */ -body .na { color: #7D9029 } /* Name.Attribute */ -body .nb { color: #954121 } /* Name.Builtin */ -body .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -body .no { color: #880000 } /* Name.Constant */ -body .nd { color: #AA22FF } /* Name.Decorator */ -body .ni { color: #999999; font-weight: bold } /* Name.Entity */ -body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -body .nf { color: #0000FF } /* Name.Function */ -body .nl { color: #A0A000 } /* Name.Label */ -body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -body .nt { color: #954121; font-weight: bold } /* Name.Tag */ -body .nv { color: #19469D } /* Name.Variable */ -body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -body .w { color: #bbbbbb } /* Text.Whitespace */ -body .mf { color: #666666 } /* Literal.Number.Float */ -body .mh { color: #666666 } /* Literal.Number.Hex */ -body .mi { color: #666666 } /* Literal.Number.Integer */ -body .mo { color: #666666 } /* Literal.Number.Oct */ -body .sb { color: #219161 } /* Literal.String.Backtick */ -body .sc { color: #219161 } /* Literal.String.Char */ -body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */ -body .s2 { color: #219161 } /* Literal.String.Double */ -body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -body .sh { color: #219161 } /* Literal.String.Heredoc */ -body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -body .sx { color: #954121 } /* Literal.String.Other */ -body .sr { color: #BB6688 } /* Literal.String.Regex */ -body .s1 { color: #219161 } /* Literal.String.Single */ -body .ss { color: #19469D } /* Literal.String.Symbol */ -body .bp { color: #954121 } /* Name.Builtin.Pseudo */ -body .vc { color: #19469D } /* Name.Variable.Class */ -body .vg { color: #19469D } /* Name.Variable.Global */ -body .vi { color: #19469D } /* Name.Variable.Instance */ -body .il { color: #666666 } /* Literal.Number.Integer.Long */ diff --git a/public/site.js b/public/site.js deleted file mode 100644 index 752e656..0000000 --- a/public/site.js +++ /dev/null @@ -1,17 +0,0 @@ -/*! - * clipboard.js v1.5.13 - * https://zenorocha.github.io/clipboard.js - * - * Licensed MIT © Zeno Rocha - */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,o){function r(c,a){if(!n[c]){if(!e[c]){var l="function"==typeof require&&require;if(!a&&l)return l(c,!0);if(i)return i(c,!0);var s=new Error("Cannot find module '"+c+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[c]={exports:{}};e[c][0].call(u.exports,function(t){var n=e[c][1][t];return r(n?n:t)},u,u.exports,t,e,n,o)}return n[c].exports}for(var i="function"==typeof require&&require,c=0;c - - - - Go в примерах: Срезы (Slices) - - - - -
-

Go в примерах: Срезы (Slices)

- - -

- Следующий пример: Карты (Maps). -

- - -
- - - - diff --git a/public/sorting b/public/sorting deleted file mode 100644 index 3cc8fc4..0000000 --- a/public/sorting +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Сортировка (Sorting) - - - - -
-

Go в примерах: Сортировка (Sorting)

- - -

- Следующий пример: Сортировка через функции (Sorting by Functions). -

- - -
- - - - diff --git a/public/sorting-by-functions b/public/sorting-by-functions deleted file mode 100644 index fb1f2fa..0000000 --- a/public/sorting-by-functions +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Сортировка через функции (Sorting by Functions) - - - - -
-

Go в примерах: Сортировка через функции (Sorting by Functions)

- - -

- Следующий пример: Panic. -

- - -
- - - - diff --git a/public/spawning-processes b/public/spawning-processes deleted file mode 100644 index 1cc1f34..0000000 --- a/public/spawning-processes +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Порождающие процессы (Spawning Processes) - - - - -
-

Go в примерах: Порождающие процессы (Spawning Processes)

- - -

- Следующий пример: Исполняющие процессы (Exec'ing Processes). -

- - -
- - - - diff --git a/public/stateful-goroutines b/public/stateful-goroutines deleted file mode 100644 index df7ce5a..0000000 --- a/public/stateful-goroutines +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Управление состоянием горутин (Stateful Goroutines) - - - - -
-

Go в примерах: Управление состоянием горутин (Stateful Goroutines)

- - -

- Следующий пример: Сортировка (Sorting). -

- - -
- - - - diff --git a/public/string-formatting b/public/string-formatting deleted file mode 100644 index 3e8ab84..0000000 --- a/public/string-formatting +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Форматирование строк (String Formatting) - - - - -
-

Go в примерах: Форматирование строк (String Formatting)

- - -

- Следующий пример: Регулярные выражения (Regular Expressions). -

- - -
- - - - diff --git a/public/string-functions b/public/string-functions deleted file mode 100644 index 04ab05a..0000000 --- a/public/string-functions +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Строковые функции (String Functions) - - - - -
-

Go в примерах: Строковые функции (String Functions)

- - -

- Следующий пример: Форматирование строк (String Formatting). -

- - -
- - - - diff --git a/public/structs b/public/structs deleted file mode 100644 index fadbae1..0000000 --- a/public/structs +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Структуры (Structs) - - - - -
-

Go в примерах: Структуры (Structs)

- - -

- Следующий пример: Методы (Methods). -

- - -
- - - - diff --git a/public/switch b/public/switch deleted file mode 100644 index 4f7cf2f..0000000 --- a/public/switch +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Go в примерах: Switch - - - - -
-

Go в примерах: Switch

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Switch помогает проверять условие в нескольких блоках

- -
- - -
- - - -
package main
-
- -
- - - -
import (
-    "fmt"
-    "time"
-)
-
- -
- - - -
func main() {
-
- -
-

Стандартное использование switch.

- -
- -
    i := 2
-    fmt.Print("Write ", i, " as ")
-    switch i {
-    case 1:
-        fmt.Println("one")
-    case 2:
-        fmt.Println("two")
-    case 3:
-        fmt.Println("three")
-    }
-
- -
-

Вы можете использовать запятую в качестве разделителя, -для перечисления нескольких значений в case. -Так же в данном примере используется блок -по-умолчанию default.

- -
- -
    switch time.Now().Weekday() {
-    case time.Saturday, time.Sunday:
-        fmt.Println("It's the weekend")
-    default:
-        fmt.Println("It's a weekday")
-    }
-
- -
-

switch без условия аналогичен обычному оператору -if/else по своей логике. Так же в этом примере -что в case можно использовать не только константы.

- -
- -
    t := time.Now()
-    switch {
-    case t.Hour() < 12:
-        fmt.Println("It's before noon")
-    default:
-        fmt.Println("It's after noon")
-    }
-
- -
-

В этой конструкции switch сравниваются типы значений. -Вы можете использовать этот прием, для определения -типа значения интерфейса.

- -
- -
    whatAmI := func(i interface{}) {
-        switch t := i.(type) {
-        case bool:
-            fmt.Println("I'm a bool")
-        case int:
-            fmt.Println("I'm an int")
-        default:
-            fmt.Printf("Don't know type %T\n", t)
-        }
-    }
-    whatAmI(true)
-    whatAmI(1)
-    whatAmI("hey")
-}
-
- -
- - - - - - - - -
- - - -
$ go run switch.go 
-Write 2 as two
-It's a weekday
-It's after noon
-I'm a bool
-I'm an int
-Don't know type string
-
- -
- - -

- Следующий пример: Массивы (Arrays). -

- - -
- - - - diff --git a/public/temporary-files-and-directories b/public/temporary-files-and-directories deleted file mode 100644 index 0bb9089..0000000 --- a/public/temporary-files-and-directories +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Временные файлы и директории (Temporary Files and Directories) - - - - -
-

Go в примерах: Временные файлы и директории (Temporary Files and Directories)

- - -

- Следующий пример: Тестирование (Testing). -

- - -
- - - - diff --git a/public/testing b/public/testing deleted file mode 100644 index ae3d56f..0000000 --- a/public/testing +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Тестирование (Testing) - - - - -
-

Go в примерах: Тестирование (Testing)

- - -

- Следующий пример: Аргументы командной строки (Command-Line Arguments). -

- - -
- - - - diff --git a/public/tickers b/public/tickers deleted file mode 100644 index e33731e..0000000 --- a/public/tickers +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Тикеры (повторения) (Tickers) - - - - -
-

Go в примерах: Тикеры (повторения) (Tickers)

- - -

- Следующий пример: Пулы воркеров (Worker Pools). -

- - -
- - - - diff --git a/public/time b/public/time deleted file mode 100644 index 75f4c6d..0000000 --- a/public/time +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Время (Time) - - - - -
-

Go в примерах: Время (Time)

- - -

- Следующий пример: Epoch. -

- - -
- - - - diff --git a/public/time-formatting-parsing b/public/time-formatting-parsing deleted file mode 100644 index 176c27a..0000000 --- a/public/time-formatting-parsing +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Форматирование времени (Time Formatting / Parsing) - - - - -
-

Go в примерах: Форматирование времени (Time Formatting / Parsing)

- - -

- Следующий пример: Случайные числа (Random Numbers). -

- - -
- - - - diff --git a/public/timeouts b/public/timeouts deleted file mode 100644 index 0ab0267..0000000 --- a/public/timeouts +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Тайм-ауты (Timeouts) - - - - -
-

Go в примерах: Тайм-ауты (Timeouts)

- - -

- Следующий пример: Неблокируемые операции в каналах (Non-Blocking Channel Operations). -

- - -
- - - - diff --git a/public/timers b/public/timers deleted file mode 100644 index 20484a9..0000000 --- a/public/timers +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Таймеры (Timers) - - - - -
-

Go в примерах: Таймеры (Timers)

- - -

- Следующий пример: Тикеры (повторения) (Tickers). -

- - -
- - - - diff --git a/public/url b/public/url deleted file mode 100644 index 6c42ddc..0000000 --- a/public/url +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Парсинг URL (URL Parsing) - - - - -
-

Go в примерах: Парсинг URL (URL Parsing)

- - -

- Следующий пример: Хеш SHA1 (SHA1 Hashes). -

- - -
- - - - diff --git a/public/values b/public/values deleted file mode 100644 index 3abd5d6..0000000 --- a/public/values +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Типы данных (Values) - - - - -
-

Go в примерах: Типы данных (Values)

- - -

- Следующий пример: Переменные (Variables). -

- - -
- - - - diff --git a/public/variables b/public/variables deleted file mode 100644 index cacb411..0000000 --- a/public/variables +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Переменные (Variables) - - - - -
-

Go в примерах: Переменные (Variables)

- - -

- Следующий пример: Константы (Constants). -

- - -
- - - - diff --git a/public/variadic-functions b/public/variadic-functions deleted file mode 100644 index 53e6729..0000000 --- a/public/variadic-functions +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Функции с переменным числом аргументов (Variadic Functions) - - - - -
-

Go в примерах: Функции с переменным числом аргументов (Variadic Functions)

- - -

- Следующий пример: Замыкания (Closures). -

- - -
- - - - diff --git a/public/waitgroups b/public/waitgroups deleted file mode 100644 index 11682c0..0000000 --- a/public/waitgroups +++ /dev/null @@ -1,226 +0,0 @@ - - - - - Go в примерах: WaitGroups - - - - -
-

Go в примерах: WaitGroups

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Для ожидания выполнения нескольких горутин, мы можем -использовать встроенную конструкцию WaitGroup.

- -
- - -
- - - -
package main
-
- -
- - - -
import (
-    "fmt"
-    "sync"
-    "time"
-)
-
- -
-

Эта функция, которую мы будем запускать в каждой -горутине. Обратите внимание, что WaitGroup должна -быть передана в функцию по указателю.

- -
- -
func worker(id int, wg *sync.WaitGroup) {
-    fmt.Printf("Worker %d starting\n", id)
-
- -
-

Sleep симулирует тяжелую задачу.

- -
- -
    time.Sleep(time.Second)
-    fmt.Printf("Worker %d done\n", id)
-
- -
-

Оповестить WaitGroup что воркер выполнился

- -
- -
    wg.Done()
-}
-
- -
- - - -
func main() {
-
- -
-

Эта WaitGroup используется для ожидания выполнения -всех горутинё запущенных здесь.

- -
- -
    var wg sync.WaitGroup
-
- -
-

Запускаем несколько горутин и инкрементируем счетчик -в WaitGroup для каждой запущенной горутины.

- -
- -
    for i := 1; i <= 5; i++ {
-        wg.Add(1)
-        go worker(i, &wg)
-    }
-
- -
-

Блокируем звершение программы до момента, пока -счетчик WaitGroup снова не станет равным 0. -Это будет означать, что все горутины выполнились.

- -
- -
    wg.Wait()
-}
-
- -
- - - - - - - - - - - - - -
- - - -
$ go run waitgroups.go
-Worker 5 starting
-Worker 3 starting
-Worker 4 starting
-Worker 1 starting
-Worker 2 starting
-Worker 4 done
-Worker 1 done
-Worker 2 done
-Worker 5 done
-Worker 3 done
-
- -
-

Порядок воркеров начинающихся и выполненных, вероятно -будет изменяться при каждом запуске.

- -
- - -
- - -

- Следующий пример: Ограничение скорости (Rate Limiting). -

- - -
- - - - diff --git a/public/worker-pools b/public/worker-pools deleted file mode 100644 index 052fe79..0000000 --- a/public/worker-pools +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Пулы воркеров (Worker Pools) - - - - -
-

Go в примерах: Пулы воркеров (Worker Pools)

- - -

- Следующий пример: WaitGroups. -

- - -
- - - - diff --git a/public/writing-files b/public/writing-files deleted file mode 100644 index fd622c1..0000000 --- a/public/writing-files +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Go в примерах: Запись файлов (Writing Files) - - - - -
-

Go в примерах: Запись файлов (Writing Files)

- - -

- Следующий пример: Строковые фильтры (Line Filters). -

- - -
- - - - diff --git a/public/xml b/public/xml deleted file mode 100644 index 95f1a49..0000000 --- a/public/xml +++ /dev/null @@ -1,288 +0,0 @@ - - - - - Go в примерах: XML - - - - -
-

Go в примерах: XML

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Go предлагает встроенную поддержку XML и -XML-подобных форматов с пакетом encoding.xml.

- -
- - -
- - - -
package main
-
- -
- - - -
import (
-    "encoding/xml"
-    "fmt"
-)
-
- -
-

Этот тип будет сопоставлен с XML. Как и в примерах JSON, -теги полей содержат директивы для кодера и декодера. -Здесь мы используем некоторые особенности пакета XML: -XMLName определяет имя элемента XML, представляющего -эту структуру; id,attr означает, что поле Id является -атрибутом XML, а не вложенным элементом.

- -
- -
type Plant struct {
-    XMLName xml.Name `xml:"plant"`
-    Id      int      `xml:"id,attr"`
-    Name    string   `xml:"name"`
-    Origin  []string `xml:"origin"`
-}
-
- -
- - - -
func (p Plant) String() string {
-    return fmt.Sprintf("Plant id=%v, name=%v, origin=%v",
-        p.Id, p.Name, p.Origin)
-}
-
- -
- - - -
func main() {
-    coffee := &Plant{Id: 27, Name: "Coffee"}
-    coffee.Origin = []string{"Ethiopia", "Brazil"}
-
- -
-

Создаем XML, представляющий наш plant; -использование MarshalIndent для создания более -читабельного вывода.

- -
- -
    out, _ := xml.MarshalIndent(coffee, " ", "  ")
-    fmt.Println(string(out))
-
- -
-

Чтобы добавить общий заголовок XML к выводу, добавьте -его явно.

- -
- -
    fmt.Println(xml.Header + string(out))
-
- -
-

Используйте Unmarhshal для парсинга байтов с XML в -структуру данных. Если XML имеет неправильный формат -или не может быть преобразован в Plant, будет -возвращена описательная ошибка.

- -
- -
    var p Plant
-    if err := xml.Unmarshal(out, &p); err != nil {
-        panic(err)
-    }
-    fmt.Println(p)
-
- -
- - - -
    tomato := &Plant{Id: 81, Name: "Tomato"}
-    tomato.Origin = []string{"Mexico", "California"}
-
- -
-

Поле parent>child>plant сообщает кодировщику о -необходимости вложения всех plant в -<parent><child>...

- -
- -
    type Nesting struct {
-        XMLName xml.Name `xml:"nesting"`
-        Plants  []*Plant `xml:"parent>child>plant"`
-    }
-
- -
- - - -
    nesting := &Nesting{}
-    nesting.Plants = []*Plant{coffee, tomato}
-
- -
- - - -
    out, _ = xml.MarshalIndent(nesting, " ", "  ")
-    fmt.Println(string(out))
-}
-
- -
- - - - - - - - -
- - - -
$ go run xml.go
- <plant id="27">
-   <name>Coffee</name>
-   <origin>Ethiopia</origin>
-   <origin>Brazil</origin>
- </plant>
-<?xml version="1.0" encoding="UTF-8"?>
- <plant id="27">
-   <name>Coffee</name>
-   <origin>Ethiopia</origin>
-   <origin>Brazil</origin>
- </plant>
-Plant id=27, name=Coffee, origin=[Ethiopia Brazil]
- <nesting>
-   <parent>
-     <child>
-       <plant id="27">
-         <name>Coffee</name>
-         <origin>Ethiopia</origin>
-         <origin>Brazil</origin>
-       </plant>
-       <plant id="81">
-         <name>Tomato</name>
-         <origin>Mexico</origin>
-         <origin>California</origin>
-       </plant>
-     </child>
-   </parent>
- </nesting>
-
- -
- - -

- Следующий пример: Время (Time). -

- - -
- - - - diff --git a/tools/generate.go b/tools/generate.go index 4fd2dd3..1c22ada 100644 --- a/tools/generate.go +++ b/tools/generate.go @@ -238,7 +238,7 @@ func parseAndRenderSegs(sourcePath string) ([]*Seg, string) { func parseExamples() []*Example { var exampleNames []string - re := regexp.MustCompile(`(?m)[a-z0-9]{1}[a-z0-9\-]{1,}[a-z0-9]{1}`) + for _, line := range readLines("examples.txt") { if line != "" && !strings.HasPrefix(line, "#") { exampleNames = append(exampleNames, line) @@ -249,18 +249,24 @@ func parseExamples() []*Example { if verbose() { fmt.Printf("Processing %s [%d/%d]\n", exampleName, i+1, len(exampleNames)) } - example := Example{Name: exampleName} - exampleID := strings.ToLower(exampleName) + + exampleID := exampleName + + if strings.Contains(exampleName, "|") { + parts := strings.Split(exampleName, "|") + exampleName, exampleID = parts[0], parts[1] + } + + exampleID = strings.ToLower(exampleID) exampleID = strings.Replace(exampleID, " ", "-", -1) exampleID = strings.Replace(exampleID, "/", "-", -1) exampleID = strings.Replace(exampleID, "'", "", -1) exampleID = dashPat.ReplaceAllString(exampleID, "-") - //str := `хеш-sha1-(sha1-hashes)` - //fmt.Println(re.FindString(str)) + example := Example{Name: exampleName} + + example.ID = exampleID - //example.ID = exampleID - example.ID = re.FindString(exampleID) example.Segs = make([][]*Seg, 0) sourcePaths := mustGlob("examples/" + exampleID + "/*") for _, sourcePath := range sourcePaths {