Git Product home page Git Product logo

jin's Introduction

Welcome!

I am a Software engineer who passionate about computer science / processor architecture / computer network

Currently working with Go Programming Language

⚙️  GitHub Analytics

eco's github stats 

Top Langs

linkedin

jin's People

Contributors

ecoshub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jin's Issues

suggestion: Set functions not setting a value if key not exists.

There must be a function to set or creates a key value pair if not exists.

example:

func SetValueIfNotNull(body []byte, key, value string) ([]byte, error) {
	_, err := jin.Get(body, key)
	if err != nil {
		if err.Error() == jin.ErrKeyNotFound(key).Error() {
			return jin.AddKeyValueString(body, key, value)
		}
	}
	return jin.SetString(body, value, key)
}

AddKeyValueString is not adding quote

AddKeyValueString is not adding quote to integer-convertable-string.

example:

var err error
b := jin.MakeEmptyJson()
b, err = jin.AddKeyValueString(b, "age", "3123")
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(string(b))

outpput:

{"age":3123}

expecting:

{"age":"3123"}

Because I am adding value as "String".

null json return error

In case of error some functions returning nil body.

// AddKeyValueString is a variation of AddKeyValue() func.
// Type of new value must be a string.
func AddKeyValueString(json []byte, key, value string, path ...string) ([]byte, error) {
	if len(value) == 0 {
		return nil, ErrNullNewValue()
	}
	if len(key) == 0 {
		return nil, ErrNullKey()
	}
	return AddKeyValue(json, key, []byte(formatType(value)), path...)
}

known functions:

  • Insert
  • AddKeyValueString
  • AddKeyValueInt
  • AddKeyValueFloat
  • AddKeyValueBool
  • AddString
  • InsertString
  • InsertInt
  • InsertFloat
  • Bool

walk func does not consider callback return params

jin walk.go:45
current code:

	default:
		key := ""
		if len(path) != 0 {
			key = path[len(path)-1]
		}
		val, err := Get(json, path...)
		if err != nil {
			return err
		}
		callback(key, val, path) // return control is missing
	}

must change with:

	default:
		key := ""
		if len(path) != 0 {
			key = path[len(path)-1]
		}
		val, err := Get(json, path...)
		if err != nil {
			return err
		}
		cont, err := callback(key, val, path)
		if err != nil {
			return err 
		}
		if !cont {
			return nil
		}
	}

GetType func missing json length check

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/ecoshub/jin.typeControlCore(0x14f9b68, 0x0, 0x0, 0xc000191aa0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/emreocak/go/pkg/mod/github.com/ecoshub/[email protected]/inter_type.go:134 +0x1f1
github.com/ecoshub/jin.GetType(0x14f9b68, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/emreocak/go/pkg/mod/github.com/ecoshub/[email protected]/inter_type.go:50 +0x98

setting 'nil' element with 'store' is failing

package main

import (
	"fmt"

	"github.com/ecoshub/jin"
)

func main() {
	user := []byte(`{"name":"eco","age":30}`)
	var err error
	user, err = jin.Store(user, "gender", nil)
	fmt.Println(err)
	fmt.Println(string(user))
}

got:

<nil>
{"name":"eco","age":30,"gender":}

expected:

<nil>
{"name":"eco","age":30,"gender":null}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.