@gogolang

Страница 171 из 1630
Kirill
08.03.2017
19:28:35
Алексей
08.03.2017
22:05:21
Кто работал с mssql & go? Как боролись с bad connection?

Semyon
09.03.2017
05:19:58
Котаны, смотрите какая беда. Есть софтинка, которая использует байндинги к iconv, потому что ей, бедняге, приходится обрабатывать файлы в странных кодировках

из-за того, что она использует байндинги к iconv, она не собирается на винде

Google
Николай
09.03.2017
05:20:15
Подскажет может кто, в php curl это (CURLOPT_POSTFIELDS, exampleMap) эквивалентно go form := url.Values{} form.Set(key, value) и в newRequest через strings.NewReader(form.Encode())

Semyon
09.03.2017
05:20:34
скажите пожалуйста, няши, кто-нибудь знает pure-go либу для работы с кодировками?

нужно в общем случае конвертить из UTF16-LE -> UTF-8

Aleksandr
09.03.2017
05:31:36
нужно в общем случае конвертить из UTF16-LE -> UTF-8
https://www.google.ru/search?client=ubuntu&channel=fs&q=golang+utf-16+utf-8&ie=utf-8&oe=utf-8&gfe_rd=cr&ei=sOjAWM-eK8PD7gTvkYzADw

Semyon
09.03.2017
05:33:50
а если там будет не utf16-le, а koi8-r?

я потому про либу и спрашиваю

Aleksandr
09.03.2017
05:34:51
а если там будет не utf16-le, а koi8-r?
charmap.Transformer - там несколько десятков кодировок

reader := bytes.NewReader(iter.Node().Bytes()) transformer := transform.NewReader(reader, charmap.Windows1251.NewDecoder()) buf, _ := ioutil.ReadAll(transformer)

Semyon
09.03.2017
05:43:56
mmm, sounds legit

спасибо

правда опять дохрена кода получается на каждый чих :(

Aleksandr
09.03.2017
06:10:46
правда опять дохрена кода получается на каждый чих :(
так же кстати и 16: transformer := transform.NewReader(reader, unicode.UTF16(true, unicode.ExpectBOM).NewDecoder())

Google
Николай
09.03.2017
07:45:50
Подскажет может кто, в php curl это (CURLOPT_POSTFIELDS, exampleMap) эквивалентно go form := url.Values{} form.Set(key, value) и в newRequest через strings.NewReader(form.Encode())

Yura
09.03.2017
07:53:25
Могу ошибаться, но вроде бы так POST параметры из формы и передаются, т.е. твой пример правильный

Sergey
09.03.2017
08:26:33
Товарищи, а подскажите пожалуйста зачем нужен golang/dep?

Ведь зависимости автоматом подтягиваются в IDE

пишешь типа fmt и в import пакет автоматом подтягивается

или это не управление зависимостями? )

Олег
09.03.2017
08:29:00
или это не управление зависимостями? )
Внешние зависимости, нестандартная библиотека

Sergey
09.03.2017
08:29:36
а, понял. спасибо

Никита
09.03.2017
12:57:12
кто нибудь автоматически генерит документацию для го апи? чем?

Yura
09.03.2017
12:58:06
go doc ?

Никита
09.03.2017
13:05:37
swagger
https://github.com/yvasiyarov/swagger https://github.com/go-swagger/go-swagger который?

Sergey
09.03.2017
13:06:20


Mars
09.03.2017
13:06:37
Использую последний. Сначала описываю сервис в swagger, оптом генерирую каркас сервиса и дописываю руками только бизнес логику.

Генерирую клиента.

Даже писал свой транспорт для него, напрямую к postgres, вместо HTTP.

Получился ORM

Sergey
09.03.2017
13:08:22
Может кто подскажет, можно где-нибудь посмотреть на хорошую реализацию базовых структур данных типа бинарных деревьев, связных списков? Интересно как с точки зрения Golang грамотно писать такие вещи.

Никита
09.03.2017
13:10:11
https://github.com/Workiva/go-datastructures
спасибо, буду пробовать

Google
Sergey
09.03.2017
13:22:54
Daniil
09.03.2017
15:42:08
кто нибудь автоматически генерит документацию для го апи? чем?
Посмотрите на RAML ещё. Показался лаконичнее swagger. На сайте есть генераторы для GO http://raml.org/projects/projects

Constantine
09.03.2017
15:44:17
юзаю рамл

Никита
09.03.2017
15:46:12
Спасибо! Пока пришли к выводу, что нас не так много, чтобы заморачиваться генерацией док, посмотрев на это Сохранил пока)

Daniil
09.03.2017
15:47:34
Спасибо! Пока пришли к выводу, что нас не так много, чтобы заморачиваться генерацией док, посмотрев на это Сохранил пока)
Я сам не генерил ничего, но разрабам писал на нём для ТЗ. Вроде неплохая дока получалсь, юзабельная

Никита
09.03.2017
15:50:18
есть ещё такое ощущение, что раз в проекте все пишется, соблюдая определенный стиль, можно просто парсер написать для себя отдельный Хотя могу ошибаться

Мерлин
09.03.2017
18:14:45
A Roadmap to Merging 'dep' Into the Go Toolchain https://github.com/golang/dep/wiki/Roadmap?utm_source=golangweekly&utm_medium=email

Aleksandr
09.03.2017
18:19:07
Ой, ссылочки нет. Но это было вчера прямо перед твоим комментарием

Мерлин
09.03.2017
18:20:19
(

Sergey
09.03.2017
22:23:55
Товарищи, подскажите пожалуйста новичку по регуляркам в Go

Пытаюс найти все теги

input := "<u><blue><b>СИНЯЯ СТРОКА</b></blue></u> Лалала <b>Ещё разок</b>" rr, err := regexp.Compile("<([a-z]+)([^<]+)*(?:>(.*)<\\/\\1>|\\s+\\/>)") if err != nil { fmt.Printf("%v \n", err) return } tags := rr.FindStringSubmatch(string(input)) for _, val := range tags { fmt.Println(val) }

Вот код

Валит ошибку error parsing regexp: invalid escape sequence: `\1`

Favoretti
09.03.2017
22:25:11
а зачем перед 1 два \?

\1 это reference. там escape не пройдет

Sergey
09.03.2017
22:25:36
https://regex101.com/r/cUU0Tw/4

а зачем перед 1 два \?
А без \\ выводит ./main.go:18: non-octal character in escape sequence: >

Favoretti
09.03.2017
22:31:53
кстати, чтоб не париться с дбойным эскейпом - бери стринг в `` вместо ""

и глядя сюда - https://github.com/google/re2/wiki/Syntax backreferences саппорта просто нет

Google
Sergey
09.03.2017
22:33:32
спасибо ) только что нашёл

блин...

придётся думать как мне подобную регулярку намутить...рецепт был хороший (

Favoretti
09.03.2017
22:34:25
я глядя на нее не совсем понимаю что ты хочешь ей выдрать?

Sergey
09.03.2017
22:36:45
<u><blue><b>СИНЯЯ СТРОКА</b></blue></u> и <b>Ещё разок</b>

из строки <u><blue><b>СИНЯЯ СТРОКА</b></blue></u> Лалала <b>Ещё разок</b>

Favoretti
09.03.2017
22:37:14
все между тагами <u> и <b>?

Sergey
09.03.2017
22:37:33
все, между любыми тегами

Favoretti
09.03.2017
22:38:12
ы? Т.е. только текст?

Потому как этот пердомонокль матчит что попало на самом деле :)

Sergey
09.03.2017
22:38:29
ну не, сами теги и их содержимое

в строке <u><blue><b>СИНЯЯ СТРОКА</b></blue></u> Лалала <b>Ещё разок</b>

мне нужно только <u><blue><b>СИНЯЯ СТРОКА</b></blue></u> и <b>Ещё разок</b>

Favoretti
09.03.2017
22:38:53
а <blue> не тег?

Sergey
09.03.2017
22:39:00
тег

мой собственный

регулярка что я нашёл делает всё как надо на php )

Ighar
09.03.2017
22:39:38
Sergey
09.03.2017
22:40:15
Работать как с xml не вариант?
может вариант, но строка может быть невалидной. это не покрэшит программу?

ох ладно, пойду посплю )

Google
Sergey
09.03.2017
22:40:40
повоюю завтра

Sergey
09.03.2017
22:40:47
всем спокойной ночи

Ighar
09.03.2017
22:41:01
Доброй ночи

Favoretti
09.03.2017
22:41:08
вот есть либа, которая саппортит backreference

package main import "github.com/h2so5/goback/regexp" import "fmt" func main() { input := "<u><blue><b>СИНЯЯ СТРОКА</b></blue></u> Лалала <b>Ещё разок</b>" rr, err := regexp.Compile(<([a-z]+)([^<]+)*(?:>(.*)<\/{1}>|\\s+\/>)) if err != nil { fmt.Printf("%v \n", err) return } tags := rr.FindStringSubmatch(string(input)) for _, val := range tags { fmt.Println(val) } }

тока не \1, a {1}

Мерлин
10.03.2017
04:49:16
You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML. Regular expressions are a tool that is insufficiently sophisticated to understand the constructs employed by HTML. HTML is not a regular language and hence cannot be parsed by regular expressions. Regex queries are not equipped to break down HTML into its meaningful parts. so many times but it is not getting to me. Even enhanced irregular regular expressions as used by Perl are not up to the task of parsing HTML. You will never make me crack. HTML is a language of sufficient complexity that it cannot be parsed by regular expressions. Even Jon Skeet cannot parse HTML using regular expressions. Every time you attempt to parse HTML with regular expressions, the unholy child weeps the blood of virgins, and Russian hackers pwn your webapp. Parsing HTML with regex summons tainted souls into the realm of the living. HTML and regex go together like love, marriage, and ritual infanticide. The <center> cannot hold it is too late. The force of regex and HTML together in the same conceptual space will destroy your mind like so much watery putty. If you parse HTML with regex you are giving in to Them and their blasphemous ways which doom us all to inhuman toil for the One whose Name cannot be expressed in the Basic Multilingual Plane, he comes. HTML-plus-regexp will liquify the n​erves of the sentient whilst you observe, your psyche withering in the onslaught of horror. Rege ̔̉x-based HTML parsers are the cancer that is killing StackOverflow it is too late it is too late we cannot be saved the trangession of a chi͡ld ensures regex will consume all living tissue (except for HTML which it cannot, as previously prophesied) dear lord help us how can anyone survive this scourge using regex to parse HTML has doomed humanity to an eternity of dread torture and security holes using regex as a tool to process HTML establishes a breach between this world and the dread realm of c͒ͪo͛ͫrrupt entities (like SGML entities, but more corrupt) a mere glimpse of the world of reg​ex parsers for HTML will ins​tantly transport a programmer's consciousness into a world of ceaseless screaming, he comes, the pestilent slithy regex-infection wil​l devour your HT​ML parser, application and existence for all time like Visual Basic only worse he comes he comes do not fi​ght he com̡e̶s, ̕h̵i​s un̨ho͞ly radiańcé destro҉ying all enli̍̈́̂̈́ghtenment, HTML tags lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq​uid pain, the song of re̸gular exp​ression parsing will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he final snuffing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̍ͫͥͨ ̟e̠̅s ͎a̧͈͖r̽̾̈́͒͑e n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂҉̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝Sͯ ̨̥̫͎̭̔̀ͅ Have you tried using an XML parser instead? Moderator's Note This post is locked to prevent inappropriate edits to its content. The post looks exactly as it is supposed to look - there are no problems with its content. Please do not flag it for our attention.

Andrew
10.03.2017
05:00:09
You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML. Regular expressions are a tool that is insufficiently sophisticated to understand the constructs employed by HTML. HTML is not a regular language and hence cannot be parsed by regular expressions. Regex queries are not equipped to break down HTML into its meaningful parts. so many times but it is not getting to me. Even enhanced irregular regular expressions as used by Perl are not up to the task of parsing HTML. You will never make me crack. HTML is a language of sufficient complexity that it cannot be parsed by regular expressions. Even Jon Skeet cannot parse HTML using regular expressions. Every time you attempt to parse HTML with regular expressions, the unholy child weeps the blood of virgins, and Russian hackers pwn your webapp. Parsing HTML with regex summons tainted souls into the realm of the living. HTML and regex go together like love, marriage, and ritual infanticide. The <center> cannot hold it is too late. The force of regex and HTML together in the same conceptual space will destroy your mind like so much watery putty. If you parse HTML with regex you are giving in to Them and their blasphemous ways which doom us all to inhuman toil for the One whose Name cannot be expressed in the Basic Multilingual Plane, he comes. HTML-plus-regexp will liquify the n​erves of the sentient whilst you observe, your psyche withering in the onslaught of horror. Rege ̔̉x-based HTML parsers are the cancer that is killing StackOverflow it is too late it is too late we cannot be saved the trangession of a chi͡ld ensures regex will consume all living tissue (except for HTML which it cannot, as previously prophesied) dear lord help us how can anyone survive this scourge using regex to parse HTML has doomed humanity to an eternity of dread torture and security holes using regex as a tool to process HTML establishes a breach between this world and the dread realm of c͒ͪo͛ͫrrupt entities (like SGML entities, but more corrupt) a mere glimpse of the world of reg​ex parsers for HTML will ins​tantly transport a programmer's consciousness into a world of ceaseless screaming, he comes, the pestilent slithy regex-infection wil​l devour your HT​ML parser, application and existence for all time like Visual Basic only worse he comes he comes do not fi​ght he com̡e̶s, ̕h̵i​s un̨ho͞ly radiańcé destro҉ying all enli̍̈́̂̈́ghtenment, HTML tags lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq​uid pain, the song of re̸gular exp​ression parsing will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he final snuffing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̍ͫͥͨ ̟e̠̅s ͎a̧͈͖r̽̾̈́͒͑e n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂҉̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝Sͯ ̨̥̫͎̭̔̀ͅ Have you tried using an XML parser instead? Moderator's Note This post is locked to prevent inappropriate edits to its content. The post looks exactly as it is supposed to look - there are no problems with its content. Please do not flag it for our attention.
Капитан, слишком много букав! Можно кратко, чем правильно заменить регулярки. Xml?

Mars
10.03.2017
05:46:04
Пытаюс найти все теги
http://stackoverflow.com/a/1732454/491935

А, ну да, уже было )

Yura
10.03.2017
06:07:34
Для Ruby есть парсеры html (не xhtml). Пока не слышал про такие для Go, но возможно они есть.

Мерлин
10.03.2017
06:08:09
Да вы издеваетесь

Yura
10.03.2017
06:08:58
https://godoc.org/golang.org/x/net/html

Мерлин
10.03.2017
06:11:14

Страница 171 из 1630