A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 1

Filename: geshi/geshi.php

Line Number: 3469

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3469
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 2547
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 2

Filename: geshi/geshi.php

Line Number: 3469

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3469
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 2547
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 1

Filename: geshi/geshi.php

Line Number: 3469

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3469
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3043
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 2

Filename: geshi/geshi.php

Line Number: 3469

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3469
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3043
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 1

Filename: geshi/geshi.php

Line Number: 3502

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3502
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3043
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 1

Filename: geshi/geshi.php

Line Number: 3469

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3469
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 2547
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 2

Filename: geshi/geshi.php

Line Number: 3469

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3469
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 2547
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 1

Filename: geshi/geshi.php

Line Number: 3469

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3469
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 2547
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 2

Filename: geshi/geshi.php

Line Number: 3469

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3469
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 2547
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 1

Filename: geshi/geshi.php

Line Number: 3502

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3502
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 2547
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 1

Filename: geshi/geshi.php

Line Number: 3469

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3469
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3043
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 2

Filename: geshi/geshi.php

Line Number: 3469

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3469
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3043
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 1

Filename: geshi/geshi.php

Line Number: 3502

Backtrace:

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 3502
Function: _error_handler

File: /var/www/html/application/libraries/geshi/geshi.php
Line: 2547
Function: parse_non_string_part

File: /var/www/html/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/html/application/models/Pastes.php
Line: 430
Function: syntax

File: /var/www/html/application/controllers/Main.php
Line: 592
Function: getPaste

File: /var/www/html/index.php
Line: 284
Function: require_once

reverse.go - codebin.org

reverse.go

From gig, 2 Weeks ago, written in Go, viewed 21 times.
URL http://codebin.org/view/42975170 Embed
Download Paste or View Raw
  1. package main
  2. import ("fmt"; "io/ioutil"; "os"; "strings")
  3. func main() {
  4.         rdr := os.Stdin
  5.         b, err := ioutil.ReadAll(rdr)  // b - это не строка, а вырезка из байтов!!!
  6.         if err != nil {
  7.                 panic("bad input")
  8.         }
  9.         s := strings.Split(string(b),"") // string(b) - вырезку из массива байтов -  в строку, далее делим строку на символы
  10.         // для получения символа нельзя обращаться к строке по индексу (UTF-8)
  11.         // собственно реверс
  12.         for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
  13.                         s[i], s[j] = s[j], s[i]
  14.         }
  15.         // вырезки из строк-символов объединим в строку и выведем
  16.         fmt.Println(strings.Join(s,""))
  17. }

Reply to "reverse.go"

Here you can reply to the paste above