text:
// Licensed to ClickHouse, Inc. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. ClickHouse, Inc. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

package tests

import (
	"context"
	"database/sql"
	"fmt"
	"github.com/ClickHouse/clickhouse-go/v2"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"testing"
)

type customUint8 uint8

func (f *customUint8) Scan(src any) error {
	if t, ok := src.(uint8); ok {
		*f = customUint8(t)
		return nil
	}
	return fmt.Errorf("cannot scan %T into customUint8", src)
}

func TestUInt8(t *testing.T) {
	conn, err := GetNativeConnection(nil, nil, &clickhouse.Compression{
		Method: clickhouse.CompressionLZ4,
	})
	ctx := context.Background()
	require.NoError(t, err)
	const ddl = `
			CREATE TABLE test_uint8 (
				  ID   UInt8
				, Col1 UInt8
				, Col2 Nullable(UInt8)
				, Col3 Array(UInt8)
				, Col4 Array(Nullable(UInt8))
				, Col5 UInt8
			) Engine MergeTree() ORDER BY tuple()
		`
	defer func() {
		conn.Exec(ctx, "DROP TABLE IF EXISTS test_uint8")
	}()
	type result struct {
		ColID uint8 `ch:"ID"`
		Col1  uint8
		Col2  *uint8
		Col3  []uint8
		Col4  []*uint8
		Col5  customUint8
	}
	require.NoError(t, conn.Exec(ctx, ddl))
	batch, err := conn.PrepareBatch(ctx, "INSERT INTO test_uint8")
	require.NoError(t, err)
	data := uint8(42)
	require.NoError(t, err)
	require.NoError(t, batch.Append(uint8(1), data, &data, []uint8{data}, []*uint8{&data, nil, &data}, customUint8(data)))
	require.NoError(t, batch.Append(uint8(2), data, nil, []uint8{data}, []*uint8{nil, nil, &data}, customUint8(data)))
	require.Equal(t, 2, batch.Rows())
	require.NoError(t, batch.Send())
	var (
		result1 result
		result2 result
	)
	require.NoError(t, conn.QueryRow(ctx, "SELECT * FROM test_uint8 WHERE ID = $1", 1).ScanStruct(&result1))
	require.Equal(t, data, result1.Col1)
	assert.Equal(t, data, *result1.Col2)
	assert.Equal(t, []uint8{data}, result1.Col3)
	assert.Equal(t, []*uint8{&data, nil, &data}, result1.Col4)
	require.Equal(t, customUint8(data), result1.Col5)
	require.NoError(t, conn.QueryRow(ctx, "SELECT * FROM test_uint8 WHERE ID = $1", 2).ScanStruct(&result2))
	require.Equal(t, data, result2.Col1)
	require.Nil(t, result2.Col2)
	assert.Equal(t, []uint8{data}, result2.Col3)
	assert.Equal(t, []*uint8{nil, nil, &data}, result2.Col4)
	require.Equal(t, customUint8(data), result2.Col5)
}

func TestColumnarUInt8(t *testing.T) {
	conn, err := GetNativeConnection(nil, nil, &clickhouse.Compression{
		Method: clickhouse.CompressionLZ4,
	})
	ctx := context.Background()
	require.NoError(t, err)
	const ddl = `
		CREATE TABLE test_uint8_c (
			  ID   UInt64
			, Col1 UInt8
			, Col2 Nullable(UInt8)
			, Col3 Array(UInt8)
			, Col4 Array(Nullable(UInt8))
		) Engine MergeTree() ORDER BY tuple()
		`
	defer func() {
		conn.Exec(ctx, "DROP TABLE IF EXISTS test_uint8_c")
	}()
	require.NoError(t, conn.Exec(ctx, ddl))
	batch, err := conn.PrepareBatch(ctx, "INSERT INTO test_uint8_c")
	require.NoError(t, err)
	var (
		id       []uint64
		col1Data []uint8
		col2Data []*uint8
		col3Data [][]uint8
		col4Data [][]*uint8
	)
	data := uint8(42)
	for i := 0; i < 1000; i++ {
		id = append(id, uint64(i))
		col1Data = append(col1Data, data)
		if i%2 == 0 {
			col2Data = append(col2Data, &data)
		} else {
			col2Data = append(col2Data, nil)
		}
		col3Data = append(col3Data, []uint8{
			data, data, data,
		})
		col4Data = append(col4Data, []*uint8{
			&data, nil, &data,
		})
	}
	{
		if err := batch.Column(0).Append(id); !assert.NoError(t, err) {
			return
		}
		if err := batch.Column(1).Append(col1Data); !assert.NoError(t, err) {
			return
		}
		if err := batch.Column(2).Append(col2Data); !assert.NoError(t, err) {
			return
		}
		if err := batch.Column(3).Append(col3Data); !assert.NoError(t, err) {
			return
		}
		if err := batch.Column(4).Append(col4Data); !assert.NoError(t, err) {
			return
		}
	}
	require.Equal(t, 1000, batch.Rows())
	require.NoError(t, batch.Send())
	var result struct {
		Col1 uint8
		Col2 *uint8
		Col3 []uint8
		Col4 []*uint8
	}
	require.NoError(t, conn.QueryRow(ctx, "SELECT Col1, Col2, Col3, Col4 FROM test_uint8_c WHERE ID = $1", 11).ScanStruct(&result))
	require.Nil(t, result.Col2)
	assert.Equal(t, data, result.Col1)
	assert.Equal(t, []uint8{data, data, data}, result.Col3)
	assert.Equal(t, []*uint8{&data, nil, &data}, result.Col4)
}

func TestSimpleInt(t *testing.T) {
	conn, err := GetNativeConnection(nil, nil, &clickhouse.Compression{
		Method: clickhouse.CompressionLZ4,
	})
	ctx := context.Background()
	require.NoError(t, err)
	if !CheckMinServerServerVersion(conn, 21, 9, 0) {
		t.Skip(fmt.Errorf("unsupported clickhouse version"))
		return
	}
	const ddl = "CREATE TABLE test_int (`1` Int64) Engine MergeTree() ORDER BY tuple()"
	defer func() {
		conn.Exec(ctx, "DROP TABLE IF EXISTS test_int")
	}()
	require.NoError(t, conn.Exec(ctx, ddl))
	batch, err := conn.PrepareBatch(ctx, "INSERT INTO test_int")
	require.NoError(t, err)
	require.Error(t, batch.Append(222))
}

func TestNullableInt(t *testing.T) {
	conn, err := GetNativeConnection(nil, nil, &clickhouse.Compression{
		Method: clickhouse.CompressionLZ4,
	})
	ctx := context.Background()
	require.NoError(t, err)
	if !CheckMinServerServerVersion(conn, 21, 9, 0) {
		t.Skip(fmt.Errorf("unsupported clickhouse version"))
		return
	}
	const ddl = "CREATE TABLE test_int (col1 Int64, col2 Nullable(Int64), col3 Int32, col4 Nullable(Int32), col5 Int16, col6 Nullable(Int16)) Engine MergeTree() ORDER BY tuple()"
	defer func() {
		conn.Exec(ctx, "DROP TABLE IF EXISTS test_int")
	}()
	require.NoError(t, conn.Exec(ctx, ddl))
	batch, err := conn.PrepareBatch(ctx, "INSERT INTO test_int")
	require.NoError(t, err)
	col1Data := sql.NullInt64{Int64: 1, Valid: true}
	col2Data := sql.NullInt64{Int64: 0, Valid: false}
	col3Data := sql.NullInt32{Int32: 2, Valid: true}
	col4Data := sql.NullInt32{Int32: 0, Valid: false}
	col5Data := sql.NullInt16{Int16: 3, Valid: true}
	col6Data := sql.NullInt16{Int16: 0, Valid: false}
	require.NoError(t, batch.Append(col1Data, col2Data, col3Data, col4Data, col5Data, col6Data))
	require.Equal(t, 1, batch.Rows())
	require.NoError(t, batch.Send())
	var (
		col1 sql.NullInt64
		col2 sql.NullInt64
		col3 sql.NullInt32
		col4 sql.NullInt32
		col5 sql.NullInt16
		col6 sql.NullInt16
	)
	require.NoError(t, conn.QueryRow(ctx, "SELECT * FROM test_int").Scan(&col1, &col2, &col3, &col4, &col5, &col6))
	require.Equal(t, col1Data, col1)
	require.Equal(t, col2Data, col2)
	require.Equal(t, col3Data, col3)
	require.Equal(t, col4Data, col4)
	require.Equal(t, col5Data, col5)
	require.Equal(t, col6Data, col6)
}

func TestIntFlush(t *testing.T) {
	conn, err := GetNativeConnection(nil, nil, &clickhouse.Compression{
		Method: clickhouse.CompressionLZ4,
	})
	ctx := context.Background()
	require.NoError(t, err)
	defer func() {
		conn.Exec(ctx, "DROP TABLE IF EXISTS int_flush")
	}()
	const ddl = `
		CREATE TABLE int_flush (
			  Col1 UInt8
		) Engine MergeTree() ORDER BY tuple()
		`
	require.NoError(t, conn.Exec(ctx, ddl))
	batch, err := conn.PrepareBatch(ctx, "INSERT INTO int_flush")
	require.NoError(t, err)
	vals := [1000]uint8{}

	for i := 0; i < 1000; i++ {
		vals[i] = uint8(i)
		require.NoError(t, batch.Append(vals[i]))
		if i%100 == 0 {
			if i == 0 {
				require.Equal(t, 1, batch.Rows())
			} else {
				require.Equal(t, 100, batch.Rows())
			}
			require.NoError(t, batch.Flush())
		}
	}
	require.Equal(t, 99, batch.Rows())
	batch.Send()
	rows, err := conn.Query(ctx, "SELECT * FROM int_flush")
	require.NoError(t, err)
	i := 0
	for rows.Next() {
		var col1 uint8
		require.NoError(t, rows.Scan(&col1))
		assert.Equal(t, vals[i], col1)
		i += 1
	}
}

repository: ClickHouse/clickhouse-go

repo_name: ClickHouse/clickhouse-go

branch_name: refs/heads/main


text:
DESCRIPTION = "MPEG Audio Decoder Library"
SECTION = "libs"
PRIORITY = "optional"
DEPENDS = "libid3tag"
LICENSE = "GPL"
PR = "r5"

SRC_URI = "${SOURCEFORGE_MIRROR}/mad/libmad-${PV}.tar.gz \
           file://add-pkgconfig.patch \
	   file://mad.diff \
	   file://mad-mips-h-constraint.patch"

S = "${WORKDIR}/libmad-${PV}"

SRC_URI_append_avr32 = " file://libmad-0.15.1b-avr32-optimization.patch"

inherit autotools pkgconfig

EXTRA_OECONF = "-enable-speed --enable-shared"
# The ASO's don't take any account of thumb...
EXTRA_OECONF_append_thumb = " --disable-aso --enable-fpm=default"
EXTRA_OECONF_append_arm = " --enable-fpm=arm"

do_configure_prepend () {
#	damn picky automake...
	touch NEWS AUTHORS ChangeLog
}

ARM_INSTRUCTION_SET = "arm"

SRC_URI[md5sum] = "1be543bc30c56fb6bea1d7bf6a64e66c"
SRC_URI[sha256sum] = "bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690"

license: MIT

repository: overo/overo-oe-natty

license_type: permissive

repo_name: overo/overo-oe-natty

branch_name: HEAD

extension: bb


text:
package ssm

import "fmt"

type InvalidTransitionError struct {
	Event Event
	From  State
}

func (e *InvalidTransitionError) Error() string {
	return fmt.Sprintf("Invalid transition error [Event: %v, From: %v]",
		e.Event, e.From,
	)
}

repository: rachelbluelab/gossm

repo_name: rachelbluelab/gossm

branch_name: refs/heads/master

extension: go


text:
macro(add_subdirectory_ex arg)
	message(STATUS "---------Configure ${arg}")
	add_subdirectory(${arg})
	message(STATUS "---------Done ${arg}")
endmacro()

macro(detect_platform)
	if(UNIX AND NOT APPLE)
		set(LINUX TRUE)
	endif()

	# if(NOT LINUX) should work, too, if you need that
	if(LINUX)
		message(STATUS "OS >>> Linux")
		# linux stuff here
	elseif(WIN32)
		message(STATUS "OS >>> Windows")
		# stuff that should happen not on Linux
	endif()

	message(STATUS "COMPILER >>> ${CMAKE_CXX_COMPILER_ID}")

	message(STATUS "BUILD_SHARED_LIBS >>> ${BUILD_SHARED_LIBS}")

	if(MSVC)
		add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
		add_definitions(-D_SCL_SECURE_NO_WARNINGS=1)
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj /W3")
	endif()

endmacro()

macro(print_info)
	message(STATUS "PROJECT_BINARY_DIR >>> ${PROJECT_BINARY_DIR}")
	message(STATUS "CMAKE_CXX_FLAGS >>> ${CMAKE_CXX_FLAGS}")
	message(STATUS "CMAKE_CXX_FLAGS_DEBUG >>> ${CMAKE_CXX_FLAGS_DEBUG}")
	message(STATUS "CMAKE_CXX_FLAGS_RELEASE >>> ${CMAKE_CXX_FLAGS_RELEASE}")
endmacro()

macro(set_output_paths)
	set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
	set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
endmacro()

macro(set_project_custom_defines)
	add_definitions(-DENGINE_DIRECTORY="${PROJECT_SOURCE_DIR}" -DSHADER_INCLUDE_DIRECTORY="${BGFX_DIR}/src")
endmacro()

repository: ArnCarveris/EtherealEngine

repo_name: ArnCarveris/EtherealEngine

extension: cmake


text:
package main

import (
	"fmt"

	"github.com/gin-gonic/gin"
	"springmars.com/gin-mysql-viper/config"
	"springmars.com/gin-mysql-viper/repo"
	"springmars.com/gin-mysql-viper/web"
	_ "springmars.com/gin-mysql-viper/web"
)

func main() {
	// 加载配置
	config.LoadConfig()
	// 初始化MysqlDB
	repo.InitDb()
	// 启动http服务
	listenAndServe()
	// panic 回调 recover
	defer recoverErr()
}

// listenAndServe
func listenAndServe() {
	engine := gin.Default()
	// 跨域
	engine.Use(web.Cors())
	// 循环注册
	for _, route := range web.Handlers {
		switch route.Method {
		case web.GET:
			engine.GET(route.Url, route.Handler)
		case web.POST:
			engine.POST(route.Url, route.Handler)
		case web.DELETE:
			engine.DELETE(route.Url, route.Handler)
		case web.PUT:
			engine.PUT(route.Url, route.Handler)
		case web.PATCH:
			engine.PATCH(route.Url, route.Handler)
		default:
			fmt.Println("路由注册失败:", route.Method, route.Url)
		}
	}

	fmt.Println("Http ListenAndServe:", "192.168.50.188", config.AppConf.Port)
	if err := engine.Run(fmt.Sprintf("192.168.50.188:%d", config.AppConf.Port)); err != nil {
		panic("程序启动失败:" + err.Error())
	}
}

// panic 异常退出可执行recover func
func recoverErr() {
	err := recover()
	if err != nil {
		fmt.Println(err)
	}
}


text:
SECTION = "base"
require sgml-common_${PV}.bb
inherit native

DEPENDS = ""
FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/sgml-common-${PV}"
S = "${WORKDIR}/sgml-common-${PV}"
PACKAGES = ""

do_stage () {
	install -m 0755 bin/install-catalog ${STAGING_BINDIR}/
	install -m 0755 bin/sgmlwhich ${STAGING_BINDIR}/
	install -d ${STAGING_DIR}/etc
	install -m 0644 config/sgml.conf ${STAGING_DIR}/etc/
	install -d ${STAGING_DATADIR}/sgml
	install -m 0644 xml.dcl ${STAGING_DATADIR}/sgml/
	install -d ${STAGING_DATADIR}/xml/xml-iso-entities-8879.1986
	install -m 0644 xml-iso-entities/catalog ${STAGING_DATADIR}/xml/xml-iso-entities-8879.1986/
	install -m 0644 xml-iso-entities/*.ent ${STAGING_DATADIR}/xml/xml-iso-entities-8879.1986/
	install -d ${STAGING_DATADIR}/sgml/sgml-iso-entities-8879.1986
	install -m 0644 sgml-iso-entities/catalog ${STAGING_DATADIR}/sgml/sgml-iso-entities-8879.1986/
	install -m 0644 sgml-iso-entities/*.ent ${STAGING_DATADIR}/sgml/sgml-iso-entities-8879.1986/
}

do_install () {
	:
}

repository: jdegges/gumstix-pip-oe

repo_name: jdegges/gumstix-pip-oe


text:
// Copyright (c) Jeremías Casteglione <jrmsdev@gmail.com>
// See LICENSE file.

package log

import (
	"github.com/jrmsdev/gojc/internal/logger"
)

var l *logger.Logger

func Init(level string) error {
	var err error
	l, err = logger.New(level)
	return err
}

func Levels() string {
	return logger.Levels
}

func Debug(format string, args ...interface{}) {
	l.Debug(format, args...)
}

func Warnf(format string, args ...interface{}) {
	l.Warnf(format, args...)
}

func Warn(err error) {
	l.Warn(err)
}

func Errorf(format string, args ...interface{}) {
	l.Errorf(format, args...)
}

func Error(err error) {
	l.Error(err)
}

func Printf(format string, args ...interface{}) {
	l.Printf(format, args...)
}

func Print(args ...interface{}) {
	l.Print(args...)
}

repository: jrmsgit/gojc

repo_name: jrmsgit/gojc


text:
package internal

import (
	"fmt"
	"os"
	"os/exec"
	"path/filepath"
	"syscall"

	"github.com/spf13/cobra"

	"github.com/cucumber/godog/colors"
	"github.com/cucumber/godog/internal/builder"
	"github.com/cucumber/godog/internal/flags"
)

var opts flags.Options

// CreateRunCmd creates the run subcommand.
func CreateRunCmd() cobra.Command {
	runCmd := cobra.Command{
		Use:   "run [features]",
		Short: "Compiles and runs a test runner",
		Long: `Compiles and runs test runner for the given feature files.
Command should be run from the directory of tested package and contain
buildable go source.`,
		Example: `  godog run
  godog run <feature>
  godog run <feature> <feature>

  Optional feature(s) to run:
    dir (features/)
    feature (*.feature)
    scenario at specific line (*.feature:10)
  If no feature arguments are supplied, godog will use "features/" by default.`,
		RunE:         runCmdRunFunc,
		SilenceUsage: true,
	}

	flags.BindRunCmdFlags("", runCmd.Flags(), &opts)

	return runCmd
}

func runCmdRunFunc(cmd *cobra.Command, args []string) error {
	fmt.Println(colors.Yellow("Use of godog CLI is deprecated, please use *testing.T instead."))
	fmt.Println(colors.Yellow("See https://github.com/cucumber/godog/discussions/478 for details."))

	osArgs := os.Args[1:]

	if len(osArgs) > 0 && osArgs[0] == "run" {
		osArgs = osArgs[1:]
	}

	if err := buildAndRunGodog(osArgs); err != nil {
		return err
	}

	return nil
}

func buildAndRunGodog(args []string) (err error) {
	bin, err := filepath.Abs(buildOutputDefault)
	if err != nil {
		return err
	}

	if err = builder.Build(bin); err != nil {
		return err
	}

	defer os.Remove(bin)

	return runGodog(bin, args)
}

func runGodog(bin string, args []string) (err error) {
	cmd := exec.Command(bin, args...)
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.Stdin = os.Stdin
	cmd.Env = os.Environ()

	if err = cmd.Start(); err != nil {
		return err
	}

	if err = cmd.Wait(); err == nil {
		return nil
	}

	exiterr, ok := err.(*exec.ExitError)
	if !ok {
		return err
	}

	st, ok := exiterr.Sys().(syscall.WaitStatus)
	if !ok {
		return fmt.Errorf("failed to convert error to syscall wait status. original error: %w", exiterr)
	}

	// This works on both Unix and Windows. Although package
	// syscall is generally platform dependent, WaitStatus is
	// defined for both Unix and Windows and in both cases has
	// an ExitStatus() method with the same signature.
	if st.ExitStatus() > 0 {
		return err
	}

	return nil
}

repository: cucumber/godog

repo_name: cucumber/godog

gha_license_id: MIT

gha_language: Go


text:
function sensorval( sensor,tempval,doorstate) {
  this.sensor = sensor;
  this.tempval = tempval;
  this.doorstate = doorstate;
}

sensorval.prototype.logValue = function() {
  console.log('Sensor', this.sensor);
  console.log('tempval', this.tempval);
  console.log('doorstate', this.doorstate);
  return this;
}

sensorval.prototype.getSensor = function() {
  return this.sensor;
}
sensorval.prototype.gettempval = function() {
  return this.tempval;
}
sensorval.prototype.getdoorstate = function() {
  return this.doorstate;
}

module.exports = sensorval;

repository: rodkwithnasa/rodkexpressapp

repo_name: rodkwithnasa/rodkexpressapp

gha_language: JavaScript

extension: js