Repository : http://git.fedorahosted.org/git/?p=secure-coding.git On branch : master >--------------------------------------------------------------- commit a9229ae8c68586898bf6d49487c05e511131f7a1 Author: Florian Weimer <fweimer@xxxxxxxxxx> Date: Fri May 30 14:29:22 2014 +0200 Add auto-generated XML for the Go code snippets >--------------------------------------------------------------- .../en-US/snippets/Go-Error_Handling-IO.xml | 25 ++++++++++++++++++++ .../en-US/snippets/Go-Error_Handling-Regular.xml | 23 ++++++++++++++++++ 2 files changed, 48 insertions(+), 0 deletions(-) diff --git a/defensive-coding/en-US/snippets/Go-Error_Handling-IO.xml b/defensive-coding/en-US/snippets/Go-Error_Handling-IO.xml new file mode 100644 index 0000000..818d1da --- /dev/null +++ b/defensive-coding/en-US/snippets/Go-Error_Handling-IO.xml @@ -0,0 +1,25 @@ +<?xml version='1.0' encoding='utf-8' ?> +<!DOCTYPE programlisting PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ +]> +<!-- Automatically generated file. Do not edit. --> +<programlisting language="C"> +func IOError(r io.Reader, buf []byte, processor Processor, + handler ErrorHandler) (message string, err error) { + n, err := r.Read(buf) + // First check for available data. + if n > 0 { + message, err = processor.Process(buf[0:n]) + // Regular error handling. + if err != nil { + handler.Handle(err) + return "", err + } + } + // Then handle any error. + if err != nil { + handler.Handle(err) + return "", err + } + return +} +</programlisting> diff --git a/defensive-coding/en-US/snippets/Go-Error_Handling-Regular.xml b/defensive-coding/en-US/snippets/Go-Error_Handling-Regular.xml new file mode 100644 index 0000000..c7f4bc7 --- /dev/null +++ b/defensive-coding/en-US/snippets/Go-Error_Handling-Regular.xml @@ -0,0 +1,23 @@ +<?xml version='1.0' encoding='utf-8' ?> +<!DOCTYPE programlisting PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ +]> +<!-- Automatically generated file. Do not edit. --> +<programlisting language="C"> +type Processor interface { + Process(buf []byte) (message string, err error) +} + +type ErrorHandler interface { + Handle(err error) +} + +func RegularError(buf []byte, processor Processor, + handler ErrorHandler) (message string, err error) { + message, err = processor.Process(buf) + if err != nil { + handler.Handle(err) + return "", err + } + return +} +</programlisting> -- security mailing list security@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/security